AIXChain Blockchain Document
  • INTRODUCTION
    • Getting started with smart contract development
    • Build a Decentralized Library
  • AIXC AND ARC TOKEN
    • ARC
      • ARX Transfer
      • Query ARX balance
    • ARC-10
      • Issue ARC-10 token
      • Participate ARC-10
      • ARC-10 Transfer
      • Query ARC-10 balance
      • ARC-10 Transfer in Smart Contracts
    • ARC-20
      • Protocol Interface
      • Contract Example
      • Issuing ARC-20 tokens tutorial
    • ARC-721
      • Protocol Interface
      • Contract Example
  • ACCOUNT MODEL
  • BUILD NODE
    • How to setup a Super node to produce Blocks
      • Recommended configuration & Environment
      • Example cloud services
      • Deployment guide
    • Super Representative
      • How to become a SR
      • Super Representatives Election
      • How to change witness name
  • HTTP API
    • Introduction
    • API Signature and Broadcast Flow
    • API List
      • Full Node API Overview
      • Address Utilities
        • GenerateAddress
        • CreateAddress
        • ValidateAddress
      • Accounts
        • CreateAccount
        • GetAccount
        • UpdateAccount
        • AccountPermissionUpdate
        • GetAccountBalance
      • Account Resources
        • GetAccountResource
        • GetAccountNet
        • FreezeBalance
        • UnfreezeBalance
        • GetDelegatedResource
        • GetDelegatedResourceAccountIndex
      • Query the Network
        • GetBlockByNum
        • GetBlockById
        • GetBlockByLatestNum
        • GetBlockByLimitNext
        • GetNowBlock
        • GetTransactionById
        • GetTransactionInfoById
        • GetTransactionInfoByBlockNum
        • ListNodes
        • GetNodeInfo
        • GetChainParameters
        • GetBlockBalance
      • ARC10 Token
        • GetAssetIssueByAccount
        • GetAssetIssueById
        • GetAssetIssueList
        • GetPaginatedAssetIssueList
        • TransferAsset
        • CreateAssetIssue
        • UnfreezeAsset
        • UpdateAsset
      • Transactions
        • GetContract
        • GetTransactionSign
        • BroadcastTransaction
        • BroadcastHex
        • EasyTransfer
        • EasyTransferByPrivate
        • CreateTransaction
      • Voting & SRs
        • ListWitnesses
        • CreateWitness
        • UpdateWitness
        • GetBrokerage
        • UpdateBrokerage
        • VoteWitnessAccount
        • GetReward
        • WithdrawBalance
        • GetNextMaintenanceTime
      • Smart Contracts
        • TriggerSmartContract
        • DeployContract
        • UpdateSetting
        • UpdateEnergyLimit
        • ClearAbi
        • GetContract
        • TriggerConstantContract
      • Proposals
      • Solidity Node API
    • RPC List
  • AIXCHAIN CLI
  • Aixchain SDK
    • Quickstart
    • Address and Signature
    • Sending Transaction
    • Smart Contract
  • Faucet Aixchain
  • Wallets
Powered by GitBook
On this page
  1. Aixchain SDK

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()

============= TRC transfer =============
transactionExtention
transaction {
  raw_data {
    ref_block_bytes: "\355<"
    ref_block_hash: "\325\003\3051\266\232\236\025"
    expiration: 1641471042000
    contract {
      type: TransferContract
      parameter {
        type_url: "type.googleapis.com/protocol.TransferContract"
        value: "\n\025AB\003HZSZ@r\311\373\372\255\337\342\240\020\255\v\315\260\022\025A\251\304cs\256\264t\236<\344Z\312$+\002zF\364\206\371\030\200\332\304\t"
      }
    }
    timestamp: 1641470984417
  }
}
txid: "\266\360\025\326\270<O\364j\vla$D\315I\314\207{\334\363\276\331:6[\200\216A\227\361%"
result {
  result: true
}

signedTxn
raw_data {
  ref_block_bytes: "\355<"
  ref_block_hash: "\325\003\3051\266\232\236\025"
  expiration: 1641471042000
  contract {
    type: TransferContract
    parameter {
      type_url: "type.googleapis.com/protocol.TransferContract"
      value: "\n\025AB\003HZSZ@r\311\373\372\255\337\342\240\020\255\v\315\260\022\025A\251\304cs\256\264t\236<\344Z\312$+\002zF\364\206\371\030\200\332\304\t"
    }
  }
  timestamp: 1641470984417
}
signature: "\304\3763\"\265\257y\203\376\237\372\304\342\215>\247\\wj\326\355\345\232\022\216\006\233F4\356\350\322$I\\\312v\330\r\177\256\003\372\253\311\3151\373kF\212Lm\266&f\3506L\234\270\355\224\256\000"

======== Result ========
b6f015d6b83c4ff46a0b6c612444cd49cc877bdcf3bed93a365b808e4197f125

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.

PreviousAddress and SignatureNextSmart Contract

Last updated 29 days ago