TRX
大约 2 分钟
TRX
创建 TRX 交易
POST
https://services.tokenview.io/vipapi/onchainwallet/trx?apikey={apikey}
参数
- {apikey}: 可在Tokenview API 后台管理系统获取激活状态的 APIKEY: https://services.tokenview.io
应用场景:可以用来创建TRX交易
post 请求 body 是json格式的文本,格式如下
{"owner_address":"{转出地址16进制}", "to_address":"{转入地址16进制}","amount":1,"method":"createtransaction","visible":{true表示地址是base58,false是16进制}}
详细说明请参考:TRX官方RPC文档
正确应答格式
{"result":"交易hash","jsonrpc": "2.0", "id":"viewtoken"}
错误应答格式
{"result":null,"error":{"code":错误码,"message":"错误消息提示"},"jsonrpc": "2.0", "id":"viewtoken"}
Request
curl --location 'https://services.tokenview.io/onchainwallet/trx' \
--header 'Content-Type: application/json' \
--data '{"owner_address":"TGmzDFttsXBRpU8NHbx28Tb4Pq8GopZK8x","to_address":"TERJLhmbLMAJx85kzMpc91Zuan5F96FL37","amount":1,"visible":true,"method":"createtransaction"}'
Response
{"visible":true,"txID":"86faa885b10aac7f17c4d4d8a4d94b3dc64f7722b44b7966044c8edf0e1ccc4d","raw_data":{"contract":[{"parameter":{"value":{"amount":1,"owner_address":"TGmzDFttsXBRpU8NHbx28Tb4Pq8GopZK8x","to_address":"TERJLhmbLMAJx85kzMpc91Zuan5F96FL37"},"type_url":"type.googleapis.com/protocol.TransferContract"},"type":"TransferContract"}],"ref_block_bytes":"31db","ref_block_hash":"b16decf21e06738c","expiration":1606057407000,"timestamp":1606057350364},"raw_data_hex":"0a0231db2208b16decf21e06738c4098e4ec83df2e5a65080112610a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412300a15414aa9a0ed45321706f2618384a399e3fee73f13fc12154130cfc6507f8d4d3972d8ad74f3feaeeb44b6a19f180170dca9e983df2e"}
创建 TRC20 代币交易
POST
https://services.tokenview.io/vipapi/onchainwallet/trx?apikey={apikey}
参数
- {apikey}: 可在Tokenview API 后台管理系统获取激活状态的 APIKEY: https://services.tokenview.io
应用场景:创建TRC20代币交易
post 请求 body 是json格式的文本,格式如下
{"owner_address":"{转出地址16进制}", "contract_address":"{转入地址16进制}","function_selector":"transfer(address,uint256)","parameter":"{调用合约的参数}","fee_limit":{最高手续费(单位SUN),"call_value":"转账TRX金额(单位SUN)","method":"triggersmartcontract","visible":{true表示地址是base58,false是16进制}}
详细说明请参考:TRX官方RPC文档
正确应答格式
{"result":"交易hash","jsonrpc": "2.0", "id":"viewtoken"}
错误应答格式
{"result":null,"error":{"code":错误码,"message":"错误消息提示"},"jsonrpc": "2.0", "id":"viewtoken"}
Request
curl --location 'https://services.tokenview.io/vipapi/onchainwallet/trx' \
--header 'Content-Type: application/json' \
--data '{
"contract_address": "412dd04f7b26176aa130823bcc67449d1f451eb98f",
"owner_address": "411fafb1e96dfe4f609e2259bfaf8c77b60c535b93",
"function_selector": "transfer (address, uint256)",
"parameter": "0000000000000000000000002ed5dd8a98aea00ae32517742ea5289761b2710e0000000000000000000000000000000000000000000000000000000ba43b7400",
"call_value": 0,
"fee_limit": 1000000000,
"method":"triggersmartcontract"
} '
Response
{"result":{"code":"CONTRACT_VALIDATE_ERROR","message":"4e6f20636f6e7472616374206f72206e6f7420612076616c696420736d61727420636f6e7472616374"}}
发送 RawTransaction
POST
https://services.tokenview.io/vipapi/onchainwallet/trx?apikey={apikey}
参数
- {apikey}: 可在Tokenview API 后台管理系统获取激活状态的 APIKEY: https://services.tokenview.io
应用场景:发送已经签完名打包好的交易上链。
post 请求 body 是json格式的文本,格式如下
{"txID":"{createtransaction返回的txID}", "raw_data":"{createtransaction返回的raw data}","raw_data_hex":"{16进制raw data}","signature":["签名16进制"],"method":"broadcasttransaction","visible":{true表示地址是base58,false是16进制}}
详细说明请参考:TRX官方RPC文档
正确应答格式
{"result":"交易hash","jsonrpc": "2.0", "id":"viewtoken"}
错误应答格式
{"result":null,"error":{"code":错误码,"message":"错误消息提示"},"jsonrpc": "2.0", "id":"viewtoken"}
Request
curl --location 'https://services.tokenview.io/onchainwallet/trx' \
--header 'Content-Type: application/json' \
--data '{"raw_data":"{\"contract\":[{\"parameter\":{\"value\":{\"amount\":1,\"owner_address\":\"TTRy1wgrn3gxeZybWNdKuPYU64kBLQ6Zmd\",\"to_address\":\"TGmzDFttsXBRpU8NHbx28Tb4Pq8GopZK8x\"},\"type_url\":\"type.googleapis.com/protocol.TransferContract\"},\"type\":\"TransferContract\"}],\"ref_block_bytes\":\"2ba9\",\"ref_block_hash\":\"efa970b152152a86\",\"expiration\":1606052703000,\"timestamp\":1606052647030}","raw_data_hex":"0a022ba92208efa970b152152a864098d6cd81df2e5a65080112610a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412300a1541bf89b206a6f347baf1de420f0356dccf62f2221f1215414aa9a0ed45321706f2618384a399e3fee73f13fc180170f6a0ca81df2e","signature":["7584150f82bd13ece4861e7fdb67cc4efe20da30e8467c3026db8a36951dbadca92b86a0d23a43b251bad138925f8c6025aedb9eed2c9785af1832f3d6b2b0dd01"],"txID":"923db55dd6bf012901b715debda10e2fb60fc1ff618747464da6c19720aa6188","visible":true,"method":"broadcasttransaction"}'
Response
{"code":"SIGERROR","txid":"923db55dd6bf012901b715debda10e2fb60fc1ff618747464da6c19720aa6188","message":"validate signature error 7584150f82bd13ece4861e7fdb67cc4efe20da30e8467c3026db8a36951dbadca92b86a0d23a43b251bad138925f8c6025aedb9eed2c9785af1832f3d6b2b0dd01 is signed by TBeL7J8XEKPdgvMFn9WSJNLZLTUFxRRBMb but it is not contained of permission."}