TRON Wallet RPC-API

For the specific definition of API, please refer to the following link:
API Proto

Frequently used APIs:

  • Get general info of the wallet (similar to bitcoin getinfo)
    GetAccount

  • Get balance of an address (similar to bitcoin getbalance)
    GetAccount

  • Create a new address (similar to bitcoin getnewaddress)
    You can create an address at the local system.
    And you can create a new address on blockchain by calling RPC-API createAccount, TransferAsset, or CreateTransaction (TransferContract) to make a transfer from an existing account to the new address.

  • Retrieve the list of transaction history by address (similar to bitcoin listtransactions)
    GetTransactionsFromThis
    GetTransactionsToThis

  • Check address is valid or not (regex or API command)

    Local check--- After decode58check at local, you can get a 21-byte byte array starting with 0x41 (mainnet) or 0xa0 (testnet).

    If you want to verify whether an address exists on the blockchain, you can call GetAccount.

Get Account Information

Interface Statement:
rpc GetAccount (Account) returns (Account) {}
Nodes: Full Node and Solidity Node
Parameters: Account: type in the address.
Returns: Account: returns all account information.
Functions: Query of balance list. Display of all asset information in account return.

TRX Transfer

Interface Statement:
rpc CreateTransaction (TransferContract) returns (Transaction) {}
Nodes: Full Node
Parameters: TransferContract: addresses of the sender and the recipient, and amount of transfer (in sun).
Returns: Transaction: returns transaction of transfer contract; request transaction after aquisition of wallet signature.
Functions: Transfer. Creation of a transaction of transfer.

Transaction Broadcasting

Interface Statement:
rpc BroadcastTransaction (Transaction) returns (Return) {}
Nodes: Full Node
Parameters: Transaction: transaction signed by wallet. In TRON network, operations entailing change of blockchain status are sealed in the transaction.
Returns: Return: success or failure. Transaction will be initiated and returned with feedback before broadcasting takes place. Note: return of success doesn’t necessarily mean completion of transaction.
Function: Transfer, vote, issuance of token, or participation in token offering. Sending signed transaction information to node, and broadcasting it to the entire network after witness verification.

Creating Account

Interface Statement:
rpc CreateAccount (AccountCreateContract) returns (Transaction){}
Nodes: Full Node
Parameters: AccountCreateContract: account type and account address.
Returns: Transaction: returns transaction of account creation. Request broadcasting after obtaining wallet signature.
Function: Account creation. Creating an account (or opting otherwise) when registering a wallet.

Account Update

Interface Statement:
rpc UpdateAccount (AccountUpdateContract) returns (Transaction){}
Nodes: Full Node
Parameters: AccountUpdateContract: account name and address.
Returns: Transaction: Returns transaction of account update. Request broadcasting after the transaction is signed by wallet.
Function: Account name update.

Vote

Interface Statement:
rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction){}
Nodes: Full Node
Parameters:
VoteWitnessContract: voter address and list of candidates which includes candidate address and number of votes received.
Returns: Transaction: returns transaction of votes. Request broadcasting after the transaction is signed by wallet.
Function: Vote. Coin holders can only vote for Super Representative candidates, with no more votes than the amount of frozen balance (see also: Balance Freeze).

Token Issuance

Interface Statement:
rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) {}
Node: Full Node
Parameters: AssetIssueContract: issuer address, token name, total capitalization, exchange rate to TRX, starting date, expiry date, attenuation coefficient, votes, detailed description, url, maximum bandwidth consumption, total bandwidth consumption and frozen token.
Returns: Transaction: returns transaction of token issuance. Request for transaction broadcasting after the transaction is signed by wallet.
Function: Token issuance. All users can issue tokens at the cost of 1024 TRX. Following a successful issuance, users can exchange for tokens with TRX before the designated expiry date.
Sample:
assetissue password abc 1000000 1 1 2018-5-31 2018-6-30 abcdef a.com 1000 1000000 200000 180 300000 365

With the above command the token named abc is issued with a total capitalization of 1 million tokens at an exchange rate of 1:1 to trx. Its offering is from May 31-June 30, 2018. It is described as abcdef and can be found at a.com.

A maximum of 1000 bandwidth points can be charged from the issuer’s account per account per day. The maximum bandwidth points to be charged from the issuer per day is 1000,000. 200,000 tokens will be locked for 180 days while another 300,000 tokens will be locked for 365 days.

Query List of SR Candidates

Interface Statement:
rpc ListWitnesses (EmptyMessage) returns (WitnessList) {}
Nodes: Full Node and Solidity Node
Parameters: EmptyMessage: null.
Returns: WitnessList: list of witnesses including detailed information of the candidates.
Function: Query of all candidates prior to voting returning detailed information on each candidate for users’ reference.

Super Representative Application

Interface Statement:
rpc CreateWitness (WitnessCreateContract) returns (Transaction) {}
Nodes: Full Node
Parameters: WitnessCreateContract: account address and Url.
Returns: Transaction: Returns a transaction of candidate application. Request broadcasting after the transaction is signed by wallet.
Function: All users with an account created on the blockchain can apply to become TRON’s Super Representative candidate.

SR Candidates Information Update

Interface Statement:
rpc UpdateWitness (WitnessUpdateContract) returns (Transaction) {}
Nodes: Full Node
Parameters: WitnessUpdateContract: an account address and Url.
Returns: Transaction: returns transaction of SR application. Request broadcasting after the transaction is signed by wallet.
Function: Updating the url of SRs.

Token Transfer

Interface Statement:
rpc TransferAsset (TransferAssetContract) returns (Transaction){}
Nodes: Full Node
Parameters: TransferAssetContract: token name, sender address, recipient address, and the amount of tokens.
Returns: Transaction: returns transaction of token transfer. Request broadcasting after the transaction is signed by wallet.
Function: Token transfer. Creates a transaction of token transfer.

Token Offering Participation

Interface Statement:
rpc ParticipateAssetIssue (ParticipateAssetIssueContract) returns (Transaction){}
Nodes: Full Node
Parameters: ParticipateAssetIssueContract: participant address, issuer address, token name, and amount of token (in sun).
Returns: Transaction: returns transaction of participation in token offering. Request broadcasting after the transaction is signed by wallet.
Function: Token Offering Participation

Nodes Query

Interface Statement:
rpc ListNodes (EmptyMessage) returns (NodeList) {}
Nodes: Full Node and Solidity Node
Parameters: EmptyMessage: null
Returns: NodeList: returns a list of nodes, including their IPs and ports.
Function: Listing the IPs and ports of current nodes.

Query List of All Tokens

Interface Statement:
rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) {}
Nodes: Full Node and Solidity Node
Parameters: EmptyMessage: null
Returns: AssetIssueList: AssetIssueContract list containing information on all issued tokens.
Function: Query list of all issued tokens. Display of all issued tokens for user’s reference.

Query Tokens Issued by an Account

Interface Statement:
rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) {}
Nodes: Full Node and Solidity Node
Parameters: Account: address
Returns: AssetIssueList: AssetIssueContract list containing information on all issued tokens.
Function: Query of all tokens issued by a given account.

Query Token Information by Token Name

Interface Statement:
rpc GetAssetIssueByName (BytesMessage) returns (AssetIssueContract) {}
Nodes: Full Node and Solidity Node
Parameters: BytesMessage: token name
Returns: AssetIssueContract: information on the token
Function: Query of token information with the name. The exclusiveness of token name is ensured on TRON’s network.

Query Current Tokens by Timestamp

Interface Statement:
rpc GetAssetIssueListByTimestamp (NumberMessage) returns (AssetIssueList){}
Nodes: Solidity Node
Parameters: NumberMessage: current timestamp (the number of milliseconds since 1970).
Returns: AssetIssueList: AssetIssueContract list including detailed information of the tokens.
Function: Query list of issued tokens by timestamList of issued tokens by timestamp. Display of current nodes for users’ reference.

Get Current Block

Interface Statement:
rpc GetNowBlock (EmptyMessage) returns (Block) {}
Nodes: Full Node and Solidity Node
Parameters: EmptyMessage: null
Returns: Block: information on current block.
Function: Inquire the latest block

Get Block by Block Height

Interface Statement:
rpc GetBlockByNum (NumberMessage) returns (Block) {}
Nodes: Full Node and Solidity Node
Parameters: NumberMessage: block height
Returns: Block: block information
Function: Accessing the block at designated height, otherwise returning to the genesis block.

Get Total Number of Transactions

Interface Statement:
rpc TotalTransaction (EmptyMessage) returns (NumberMessage) {}
Nodes: Full Node and Solidity Node
Parameters: EmptyMessage: null
Returns: NumberMessage: Total number of transactions.
Function: Inquiring the total number of transactions.

Query Transaction by ID

Interface Statement:
rpc getTransactionById (BytesMessage) returns (Transaction) {}
Nodes: Solidity Node
Parameters: BytesMessage: transaction ID or Hash
Returns: Transaction: Queried transaction
Function: Query of transaction details by ID which is the Hash of transaction.

Query Transaction by Timestamp

Interface Statement:
rpc getTransactionsByTimestamp (TimeMessage) returns (TransactionList) {}
Nodes: Solidity Node
Parameters: TimeMessage: starting time and ending time.
Returns: TransactionList: transaction list.
Function: Query of transactions by starting and ending time.

Query Transaction Initiations by Address

Interface Statement:
rpc getTransactionsFromThis (Account) returns (TransactionList) {}
Nodes: Solidity Node
Parameters: Account: initiator‘s account (address).
Returns: TransactionList: transaction list.
Function: Query of transaction initiations by account address.

Query Transaction Receptions by Address

Interface Statement:
rpc getTransactionsToThis (Account) returns (NumberMessage) {}
Nodes: Solidity Node
Parameters: Account: Recipient account (address).
Returns: TransactionList: transaction list.
Function: Query of all transactions accepted by one given account.

Freeze Balance

Interface Statement:
rpc FreezeBalance (FreezeBalanceContract) returns (Transaction) {}
Nodes: Full Node
Parameters: FreezeBalanceContract: address, amount of trx to freeze and frozen duration. Currently balance can only be frozen for 3 days.
Returns: Transaction: Return includes a transaction of balance. Request transaction broadcasting after signed by wallet.
Function: Two things can be gained through freezing balance:
a. Bandwidth Points.
b. Tron Power.

Unfreeze Balance

Interface Statement
rpc UnfreezeBalance (UnfreezeBalanceContract) returns (Transaction) {}
Nodes: Full Node
Parameters: UnfreezeBalanceContract: address.
Returns: Transaction: returns unfreeze TRX transaction. Request transaction broadcasting after signed by wallet.
Function: Balance can be unfrozen only 3 days after the latest freeze. Voting records will be cleared upon unfrozen balance, while bandwidth points won’t be. Frozen balance will not be automatically unfrozen after 3 days’ duration.

Block-production Reward Redemption

Interface Statement:
rpc WithdrawBalance (WithdrawBalanceContract) returns (Transaction) {}
Nodes: Full Node
Parameters: WithdrawBalanceContract: address
Returns: Transaction: returns withdraw TRX transaction. Request transaction broadcasting after signed by wallet.
Function: This interface is only accessible to Super Representatives. Super Representative can obtain reward after successful account keeping. Instead of saved to account balance, rewards will be held independently in account allowance, with 1 permitted withdrawal to account balance every 24 hours.

Unfreeze balance

Interface Statement:
rpc UnfreezeAsset (UnfreezeAssetContract) returns (Transaction) {}
Nodes: Full Node
Parameters: UnfreezeAssetContract: address
Returns: Transaction: returns unfreeze token transaction; request broadcasting after the transaction is signed by wallet.
Function: Token issuers can unfreeze locked supply during issuance.

Query Next Maintenance Time

Interface Statement:
rpc GetNextMaintenanceTime (EmptyMessage) returns (NumberMessage) {}
Nodes: Full Node
Parameters: EmptyMessage: no parameter needed
Returns: NumberMessage: the next maintenance time
Function: Get the next maintenance time

Query Transaction Information

Interface Statement:
rpc GetTransactionInfoById (BytesMessage) returns (TransactionInfo) {}
Node: Solidity Node
Parameters: BytesMessage: transaction ID
Returns: TransactionInfo: transaction information.
Function: Query of transaction fee, block location and the timestamp of the block.

Query Block by ID

Interface Statement:
rpc GetBlockById (BytesMessage) returns (Block) {}
Node: Full Node
Parameter: BytesMessage: block ID
Returns: Block: the block
Function: Query of block by block ID

Token update

Interface Statement:
rpc UpdateAsset (UpdateAssetContract) returns (Transaction) {}
Node: Full Node
Parameters: UpdateAssetContract: issuer address, token description, token url, maximum bandwidth consumption by each account and total bandwidth consumption.
Returns: Transaction: returns transaction; request broadcasting after the transaction is signed by wallet.
Function: Token update can only be initiated by the token issuer to update token description, url, maximum bandwidth consumption by each account and total bandwidth consumption.

Paginated Query of Token List

Interface Statement:
rpc GetPaginatedAssetIssueList (PaginatedMessage) returns (AssetIssueList) {}
Nodes: Full Node and Solidity Node.
Parameters: PaginatedMessage: starting index (0) and the number of tokens displayed on each page.
Returns: AssetIssueList: a paginated list of AssetIssueContract containing detailed information of tokens.
Function: Paginated list of tokens displaying tokens information for users’ reference.

Transaction Signing

Interface Statement:
rpc GetTransactionSign (TransactionSign) returns (Transaction) {}
Node: Full Node
Parameters: TransactionSign: Transaction to be signed and the private key to sign with.
Returns: Transaction: transaction to be signed.

Address and Private Key Creation

Interface Statement:
rpc CreateAdresss (BytesMessage) returns (BytesMessage) {}
Nodes: Full Node
Parameters: BytesMessage: Passphrase
Returns: BytesMessage: address

TRX Easy Transfer

Interface Statement:
rpc EasyTransfer (EasyTransferMessage) returns (EasyTransferResponse) {}
Nodes: Full Node
Parameters: EasyTransferMessage: password for transfer, toAddress and the amount of tokens to transfer.
Returns: EasyTransferResponse: the transaction of a transfer and the result of broadcasting.

Generate Address and Private Key

Interface Statement:
rpc GenerateAddress (EmptyMessage) returns (AddressPrKeyPairMessage) {}
Nodes: Full Node and Solidity Node
Parameters: EmptyMessage: null.
Returns: AddressPrKeyPairMessage: generate address and private key.
Function: Address and private key generation. Please invoke this API only on a trusted offline node to prevent private key leakage.