在TRON中检测TRX或TRC10事务涉及3种类型的合约:
- TransferConract(系统合同类型)
- TransferAssetContract(系统合同类型)
- TriggerSmartContract(智能合约类型)
Transaction,TransactionInfo 和 Block 的数据包含所有智能合约交易信息。
TransferContract 和 TransferAssetContract 分别是用于转移TRX和TRC10的系统合同
事务只包含一个契约,因此查询事务使用接口 GetTransactionbyId 获取有关契约的特定信息。
使用GetBlockByNum 来检索打包事务的块信息
TransferContract
- owner_address( Bytes)是TRX发件人地址。需要将字节转换为base58Check字符串以显示可读的TRON地址。
- to_address( Bytes)是TRX接收器地址。需要将字节转换为base58Check字符串。
- amount( int64)是发送到合同地址的TRX金额。
下图为TransferContract交易
{"ret":[{"contractRet":"SUCCESS"}],"signature":["aa5f69104f70e961cacfcf6cbc7710fc5820135f1b39effd394d6690b243df30b34f389741df923f665cc20521f217aeb06914abe6776510fe0277555e10203401"],"txID":"9aedad431ed596035eb44656a6c23bd43849c5e2a8161483c5c7426d7f246363","raw_data":{"contract":[{"parameter":{"value":{"amount":1318520000,"owner_address":"41fcf62171f6837cdb078460753aec8b8353f51be9","to_address":"41ec5f9648b3ba5d70c8dfc8beca5af9ef24e16746"},"type_url":"type.googleapis.com/protocol.TransferContract"},"type":"TransferContract"}],"ref_block_bytes":"0bc9","ref_block_hash":"78471e96bbb26ab2","expiration":1653443076000,"timestamp":1653443018811},"raw_data_hex":"0a020bc9220878471e96bbb26ab240a0bf8cc78f305a69080112650a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412340a1541fcf62171f6837cdb078460753aec8b8353f51be9121541ec5f9648b3ba5d70c8dfc8beca5af9ef24e1674618c089dcf40470bb8089c78f30"}
TransferAssetContract
- asset_name( String)是TRC10 ID。无需转换即可显示可读的TRON地址。 (此参数用于表示TRC10令牌的名称。在TRON改进建议#14通过以允许相同名称令牌后,此参数已被修改为TRC10 ID)。
- owner_address( Bytes)是TRC10发送方地址。需要将字节转换为base58Check字符串以显示可读的TRON地址。
- to_address( Bytes)是TRC10接收器地址。需要将字节转换为base58Check字符串以显示可读的TRON地址。
- amount( int64)是发送到合同地址的TRC10金额
{"ret":[{"contractRet":"SUCCESS"}],"signature":["839a4725029a5d6f6f368bd79ad193351a778dfe62db1fab63494993b98b8eec81836dc337cc34a93c8a9ab0d1672c0044d69578c47533b1d9106dda8ed768ad00"],"txID":"53c80ebb9f5b6396b00de6499ab565b9bc7e5757667a646690fa403ac6af89f5","raw_data":{"data":"436f6e67726174756c6174696f6e73206f6e2067657474696e67205454432e53776170206174206f6b747463c2b7636f6d202831545443203d2035355452582920e588b06f6b747463c2b7636f6de5858ce68f9b","contract":[{"parameter":{"value":{"amount":666,"asset_name":"31303031363131","owner_address":"4145ee7c5e00e9258963f2c868fc3246fc11b5b6d7","to_address":"4181b721aa557270fa387d438967a88560f57ec273"},"type_url":"type.googleapis.com/protocol.TransferAssetContract"},"type":"TransferAssetContract"}],"ref_block_bytes":"0bc9","ref_block_hash":"78471e96bbb26ab2","expiration":1653443076000,"timestamp":1653443018981},"raw_data_hex":"0a020bc9220878471e96bbb26ab240a0bf8cc78f305254436f6e67726174756c6174696f6e73206f6e2067657474696e67205454432e53776170206174206f6b747463c2b7636f6d202831545443203d2035355452582920e588b06f6b747463c2b7636f6de5858ce68f9b5a74080212700a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e736665724173736574436f6e7472616374123a0a073130303136313112154145ee7c5e00e9258963f2c868fc3246fc11b5b6d71a154181b721aa557270fa387d438967a88560f57ec273209a0570e58189c78f30"}
asset_name TRC10 ID和代币对应关系官方区块链浏览器可以查询
TRONSCAN | TRON BlockChain Explorer | 波场区块链浏览器
TriggerSmartContract
- owner_address( Bytes)是TRX或TRC10发送方地址。需要将地址从Bytes转换为base58Check String以显示可读的TRON地址。
- contract_address( Bytes)是TRX或TRC10接收者的地址,它必须是一个智能合约地址。需要将地址从Bytes转换为base58Check String以显示可读的TRON地址。
- call_value( int64)是发送到合同地址的TRX金额。
- call_token_value( int64)是发送到合同地址的TRC10金额。
- token_id( String)是相关的TRC10 ID。
- 在InternalTransaction中检查转移
- caller_address( Bytes)是TRX或TRC10令牌发送方地址。应将字节转换为base58Check字符串以显示可读的TRON地址。
- transferTo_address( Bytes)是TRX或TRC10令牌接收器地址。应将字节转换为base58Check字符串以显示可读的TRON地址。
- CallValueInfo是传输详细信息的列表。
- callvalue( int64)代表tokenId为空时的TRX数量。否则,它是令牌传输值。
- tokenId(String)是令牌标识符。 rejected表示此内部交易是否失败并被拒绝。如果rejected是’TRUE`,则不需要处理当前的内部事务,因为发生了一些错误。否则,值“false”表示成功的事务。
{"ret":[{"contractRet":"SUCCESS"}],"signature":["1af60b50336f81f1fbb63b8e665a9624f241581193739d124052e7fbdaaf0f4578c3bb95f168603b9ba142008cde674f275c023622661a5a7fb2a1e4712443f900"],"txID":"311449c8201cba049ba0ea09b001c6d0648c55f5d49d7dc1db952c3998b4375f","raw_data":{"contract":[{"parameter":{"value":{"data":"a9059cbb0000000000000000000000009883301cd3f3ab090c66a5aedbb26f01922544bd0000000000000000000000000000000000000000000000000000000000989680","owner_address":"417c17cc30dac9225e9af042e01af54548e3ef6953","contract_address":"41a614f803b6fd780986a42c78ec9c7f77e6ded13c"},"type_url":"type.googleapis.com/protocol.TriggerSmartContract"},"type":"TriggerSmartContract"}],"ref_block_bytes":"0bd9","ref_block_hash":"2e2746059044569f","expiration":1653443070000,"fee_limit":40000000,"timestamp":1653443010484},"raw_data_hex":"0a020bd922082e2746059044569f40b0908cc78f305aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a15417c17cc30dac9225e9af042e01af54548e3ef6953121541a614f803b6fd780986a42c78ec9c7f77e6ded13c2244a9059cbb0000000000000000000000009883301cd3f3ab090c66a5aedbb26f01922544bd000000000000000000000000000000000000000000000000000000000098968070b4bf88c78f30900180b48913"}
波场协议:https://github.com/tronprotocol/documentation/tree/master/%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3/%E6%B3%A2%E5%9C%BA%E5%8D%8F%E8%AE%AE