HcNet -V15.0.0

1.Claimable Balance

Claimable Balances can be used to “split up” a payment into two parts, which allows the sending to only depend on the sending account, and the receipt to only depend on the receiving account. An account can initiate the “send” by creating a ClaimableBalanceEntry with Create Claimable Balance, and then that entry can be claimed by the claimants specified on the ClaimableBalanceEntry at a later time with Claim Claimable Balance.

Example:-

  • Network network = new Network("HCX MainNet");
  • Server server = new Server(" https://aurora.hashcashconsultants.com");
  • AccountResponse sourceAccount;
  • try {
  • sourceAccount = server.accounts().account("GA…….3");
  • Predicate predicate=new Unconditional();
  • Claimant claimant=new Claimant("GD………...3A",predicate);
  • CreateClaimableBalanceOperation balanceOperation=new CreateClaimableBalanceOperation.Builder("0.00001", new AssetTypeNative(),Arrays.asList(claimant)).build();
  • Transaction transaction=new Transaction.Builder(sourceAccount, network).addOperation(balanceOperation).setTimeout(180).setBaseFee(Transaction.MIN_BASE_FEE).build();
  • transaction.sign(KeyPair.fromSecretSeed("SA………...O"));
  • SubmitTransactionResponse response = server.submitTransaction(transaction);
  • if(response.isSuccess()){
  • System.out.println("Success!");
  • System.out.println(response.getHash());
  • }
  • else
  • {
  • System.out.println(response.getExtras().getResultCodes().getTransactionResultCode());
  • System.out.println(response.getExtras().getResultCodes().getOperationsResultCodes());
  • }
  • } catch (Exception e) {
  • // TODO Auto-generated catch block
  • e.printStackTrace();
  • }

2.Fee-Bump Transactions

A fee-bump transaction enables any account to pay the fee for an existing transaction without the need to re-sign the existing transaction or manage sequence numbers. They’re useful if you need to increase the fee on a pre-signed transaction, or if you want to build a service that covers user fees. Unlike a regular transaction, which contains 1-100 operations, a fee-bump transaction contains a single transaction envelope.

Example:-

  • Network network = new Network("HCX MainNet");
  • Server server = new Server(" https://aurora.hashcashconsultants.com");
  • try
  • {
  • AccountResponse sourceacc = server.accounts().account("GAAI…………..HD");
  • .setBaseFee(Transaction.MIN_BASE_FEE)
  • .setTimeout(180)
  • .build();
  • innertransaction.sign(KeyPair.fromSecretSeed("SDUH………………..NWVX"));
  • FeeBumpTransaction outertransaction=new FeeBumpTransaction.Builder(innertransaction)
  • .setFeeAccount("GD5M………………...P3A")
  • .setBaseFee(Transaction.MIN_BASE_FEE)
  • .build();
  • outertransaction.sign(KeyPair.fromSecretSeed("SDRI7Y……………...TOSB4BU6S"));
  • SubmitTransactionResponse response = server.submitTransaction(outertransaction);
  • if(response.isSuccess()){
  • System.out.println("Success!");
  • System.out.println(response.getHash());
  • }
  • else
  • {
  • System.out.println(response.getExtras().getResultCodes().getOperationsResultCodes());
  • System.out.println(response.getExtras().getResultCodes().getTransactionResultCode());
  • }
  • }
  • catch(Exception e)
  • {
  • e.printStackTrace();
  • }

3.Minimum Balance

  • Minimum Balance = (2 + # of entries + # of sponsoring entries - # of sponsored entries) * base reserve

4.Sponsored Reserves

Protocol 15 introduces operations that allow an account to pay the base reserves for another account. This is done by using the Begin Sponsoring Future Reserves and End Sponsoring Future Reserves operations. The sponsoring account establishes the is-sponsoring-future-reserves-for relationship, and the sponsored account terminates it. While this relationship exists, reserve requirements that would normally accumulate on the sponsored account will now accumulate on the sponsoring account. Both operations must appear in a single transaction, which guarantees that both the sponsoring and sponsored accounts agree to every sponsorship.

Example:-

  • Network network = new Network("HCX MainNet");
  • Server server = new Server(" https://aurora.hashcashconsultants.com");
  • Asset asset=Asset.createNonNativeAsset("USD","GCFW………………………...OWE");
  • try
  • {
  • AccountResponse sourceacc = server.accounts().account("GCFWMJXRU25MQLD…………………………….7OWE");
  • BeginSponsoringFutureReservesOperation futureReservesOperation=new BeginSponsoringFutureReservesOperation.Builder("GAAIHEQGFEF2WFSK4A………………...GYPD2V7HD").setSourceAccount("GCFWMJXRU25MQ…………………………...S52CYO4WHKQJB4XPXMUEH7OWE").build();
  • ChangeTrustOperation trustOperation=new ChangeTrustOperation.Builder(asset,"922337203685.4775807").setSourceAccount("GAAIH……………………….KYWKJI4GYPD2V7HD").build();
  • EndSponsoringFutureReservesOperation futureReservesOperation2=new EndSponsoringFutureReservesOperation("GAAIHEQGFEF2………………………...7HD");
  • Transaction transaction=new Transaction.Builder(sourceacc, network)
  • .addOperation(futureReservesOperation).addOperation(trustOperation)
  • .addOperation(futureReservesOperation2).setBaseFee(Transaction.MIN_BASE_FEE)
  • .setTimeout(200)
  • .build();
  • transaction.sign(KeyPair.fromSecretSeed("SCF5D4ZHC7PYT………………………..7H5PG"));
  • transaction.sign(KeyPair.fromSecretSeed("SDUHAYBWHS65FGU…………………………...RNWVX"));
  • SubmitTransactionResponse response = server.submitTransaction(transaction);
  • if(response.isSuccess()){
  • System.out.println("Success!");
  • System.out.println(response.getHash());
  • }
  • else
  • {
  • System.out.println(response.getExtras().getResultCodes().getOperationsResultCodes());
  • System.out.println(response.getExtras().getResultCodes().getTransactionResultCode());
  • }
  • catch(Exception e)
  • {
  • e.printStackTrace();
  • }