Sending Transaction

Any operation contracting with AIXCHAIN network is a transaction. A transaction can be Aixchain transfer, ARC-10 transfer, freezing & unfreezing, voting, Etc.

The routine for sending

A normal routine for sending a transaction is:

Create -> Sign -> Broadcast -> (wait) -> Lookup and get receipt

Aixchain SDK defines the same protobufs include all RPC APIs and transaction related classes, also, Aixchain SDK wraps the functions in AixcClient.class.

An simple example

  public static void sendTrx() 
  {        
  System.out.println("============= TRC transfer =============");
   AixcClient client = new AixcClient("172.104.51.182:16669","172.104.51.182:16669","private key");        
  try {            
  TransactionExtention transactionExtention = client.transfer("414203485a535a4072C9FBFaADDfe2A010AD0BcdB0", "41a9c46373aEB4749E3CE45acA242b027A46f486f9", 20_000_000);           
      Transaction signedTxn = client.signTransaction(transactionExtention);                       
      String ret = client.broadcastTransaction(signedTxn);            
      System.out.println("======== Result ========\n" + ret.toString());        
      } 
      catch (Exception e) {
    System.out.println("error: " + e);        
    }    
  }

result:

public static void sendTrx()

In Aixchain SDK, the routine is:

  1. Create a AixcClient object with your private key.

  2. Obtain a TransactionExtention object from AixcClient.transfer().

  3. Call AixcClient.signTransaction()to sign the transaction with your private key binding with the AixcClient object.

  4. Call AixcClient.broadcastTransaction() to broadcast the transaction and get a TransactionReturn for analysis.

Last updated