TRON Developer Guide — TRC10 & TRX Transfer in Exchanges

Introduction

Detecting a TRX or TRC10 transaction in TRON involves 4 types of contracts:

  • TransferContract (System Contract Type)
  • TransferAssetContract (System Contract Type)
  • CreateSmartContract(Smart Contract Type)
  • TriggerSmartContract(Smart Contract Type)

The data for Transaction, TransactionInfo, and Block contain all the smart contract transaction information.

Detecting and Recording Transfers

The two contracts TransferContract and TransferAssetContract are system contracts used to transfer TRX and TRC10, respectively. A transaction contains only one contract, so the query transaction obtains specific information about a contract, using the interface GetTransactionbyId. Use GetBlockByNum to retrieve the block information of the packaged transactions. Either travel the Block or use GetTransactionInfoById to obtain specific transaction information. Check the root Transaction result. If Transaction.Result.code is Failed, reject this transaction. No transferring happened. Otherwise, check type in Transaction.raw to get contract type information (TransferContract or TransferAssetContract). Check parameter in Transaction.raw to get contract details according to type.

TransferContract

  • owner_address (Bytes) is the TRX sender address. Need to convert Bytes to a base58Check String to show readable TRON address.
  • to_address (Bytes) is the TRX receiver address. Need to convert Bytes to a base58Check String.
  • amount (int64) is the TRX amount sent to the contract address.

TransferAssetContract

  • asset_name (String) is the TRC10 ID. There is no need for conversion to show readable TRON address. (This parameter is used to represent the name of the TRC10 token. After the TRON Improvement Proposal #14 passed to allow for same name tokens, this has been modified to TRC10 ID).
  • owner_address (Bytes) is the TRC10 sender address. Need to convert Bytes to a base58Check String to show a readable TRON address.
  • to_address (Bytes) is the TRC10 receiver address. Need to convert Bytes to a base58Check String to show a readable TRON address.
  • amount (int64) is the TRC10 amount sent to the contract address.

Detection for CreateSmartContract and TriggerSmartContract is similar. Use GetBlockByNum to retrieve the block information of the packaged transactions. Either travel the Block or use GetTransactionInfoById to obtain specific transaction information. Check the root Transaction result. If Transaction.Result.code is FAILED, reject this transaction. No transferring happened. Otherwise, check type in Transaction.raw to get contract type information (CreateSmartContract or TriggerSmartContract). Check parameter in Transaction.raw to get contract details according to type.

CreateSmartContract

  • owner_address (Bytes) is the TRX or TRC10 sender address. Need to convert Bytes to a base58Check String to show a readable TRON address.
  • SmartContract.contract_address (Bytes) is the TRX or TRC10 receiver's address and it MUST BE a smart contract address. Due to the creation in runtime, you cannot retrieve it from the Transaction. Instead, use GetTransactionInfoById to obtain contract_address in TransactionInfo. The data needs to be converted from Bytes to a base58Check String to show a readable TRON address.
  • SmartContract.call_value (int64) is the TRX amount sent to the contract address.
  • call_token_value (int64) is the TRC10 amount sent to the contract address.
  • token_id (String) is the related TRC10 ID. There is no need for conversion to show a readable TRON address.

TriggerSmartContract

  • owner_address (Bytes) is the TRX or TRC10 sender address. The address needs to be converted from Bytes to a base58Check String to show a readable TRON address.
  • contract_address (Bytes) is the TRX or TRC10 receiver's address and it MUST BE a smart contract address. The address needs to be converted from Bytes to a base58Check String to show a readable TRON address.
  • call_value (int64) is the TRX amount sent to the contract address.
  • call_token_value (int64) is the TRC10 amount sent to the contract address.
  • token_id (String) is the related TRC10 ID.

Check Transfer in InternalTransaction

  • caller_address (Bytes) is the TRX or TRC10 token sender address. Bytes should be converted to a base58Check String to show a readable TRON address.
  • transferTo_address (Bytes) is the TRX or TRC10 token receiver address. Bytes should be converted to a base58Check String to show a readable TRON address.
  • CallValueInfo is a list of transfer details.
  • callvalue (int64) represents the TRX amount if tokenId is empty. Otherwise, it is the token transfer value.
  • tokenId (String) is the token identifier. rejected represents whether this internal transaction is failed and rejected. If rejected is true, there is no need to deal with the current internal transaction, since some error occurred. Otherwise, a value of false signifies a successful transaction.

Related Protobuf

TransferContract

TransferAssetContract

CreateSmartContract

TriggerSmartContract

Transaction

TransactionInfo

Block

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
TRON DAO

TRON DAO

The official Medium of Tron Foundation. Learn more: https://tron.network