TRC10 撤单

步骤说明

步骤一:通过 TronGrid 提供的接口服务触发智能合约创建取消订单事务(获取transaction)

步骤二:对事务进行签名

步骤三:广播事务

详细文档见 触发合约、签名和广播。

合约地址

基础币种为 TRC10 且报价币种为 TRX:4155ac3875ceaf0dfe45fe3ee7312b0994a8894097

合约方法

cancelOrder(uint256)

参数说明

parameter

该字段为合约方法 cancelOrder 需要传入的参数。

cancelOrder 合约方法有一个参数需要传入,这个参数是一个长度为64的字符串parameter字段。

参数:用户想要取消的订单ID(可通过订单查询接口获取),将该订单ID值转换为16进制的数字字符串后,把该字符串之前不足64位字符的部分用0补齐。

示例

用户 TLva2m6sx2Ya44kHUN2GZUF2PT5KcCNNUQ 将之前提交的一笔价格为0.54,数量为20的TSY卖单撤销

步骤一:调用 https://api.trongrid.io/wallet/triggersmartcontract 接口触发合约

Bodydata:

{
"contract_address": "4155ac3875ceaf0dfe45fe3ee7312b0994a8894097",
"owner_address": "417829b0adcb34405331a9910c646b5b71aeddc564",
"function_selector": "cancelOrder(uint256)",
"fee_limit": 1000000000,
"call_value": 0,
"parameter": "000000000000000000000000000000000000000000000000000000e8d4a6a95f"
}

Response:

{
"result": {
"result": true
},
"transaction": {
"txID": "83ddfa7aae3945f3aac3ef19e864e9322ae568991d377f9c4957b495d074002f",
"raw_data": {
"contract": [{
"parameter": {
"value": {
"data": "514fcac7000000000000000000000000000000000000000000000000000000e8d4a6a95f",
"owner_address": "417829b0adcb34405331a9910c646b5b71aeddc564",
"contract_address": "4155ac3875ceaf0dfe45fe3ee7312b0994a8894097"
},
"type_url": "type.googleapis.com/protocol.TriggerSmartContract"
},
"type": "TriggerSmartContract"
}],
"ref_block_bytes": "8be6",
"ref_block_hash": "96ad71060d05c018",
"expiration": 1559186685000,
"fee_limit": 1000000000,
"timestamp": 1559186626338
},
"raw_data_hex": "0a028be6220896ad71060d05c01840c8f892b6b02d5a8e01081f1289010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412540a15417829b0adcb34405331a9910c646b5b71aeddc56412154155ac3875ceaf0dfe45fe3ee7312b0994a88940972224514fcac7000000000000000000000000000000000000000000000000000000e8d4a6a95f70a2ae8fb6b02d90018094ebdc03"
}
}

步骤二:调用 https://api.trongrid.io/wallet/gettransactionsign 接口获取签名

Bodydata:

{
"transaction": {
"txID": "83ddfa7aae3945f3aac3ef19e864e9322ae568991d377f9c4957b495d074002f",
"raw_data": {
"contract": [{
"parameter": {
"value": {
"data": "514fcac7000000000000000000000000000000000000000000000000000000e8d4a6a95f",
"owner_address": "417829b0adcb34405331a9910c646b5b71aeddc564",
"contract_address": "4155ac3875ceaf0dfe45fe3ee7312b0994a8894097"
},
"type_url": "type.googleapis.com/protocol.TriggerSmartContract"
},
"type": "TriggerSmartContract"
}],
"ref_block_bytes": "8be6",
"ref_block_hash": "96ad71060d05c018",
"expiration": 1559186685000,
"fee_limit": 1000000000,
"timestamp": 1559186626338
},
"raw_data_hex": "0a028be6220896ad71060d05c01840c8f892b6b02d5a8e01081f1289010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412540a15417829b0adcb34405331a9910c646b5b71aeddc56412154155ac3875ceaf0dfe45fe3ee7312b0994a88940972224514fcac7000000000000000000000000000000000000000000000000000000e8d4a6a95f70a2ae8fb6b02d90018094ebdc03"
},
"privateKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

Response:

{
"txID": "83ddfa7aae3945f3aac3ef19e864e9322ae568991d377f9c4957b495d074002f",
"raw_data": {
"contract": [{
"parameter": {
"value": {
"data": "514fcac7000000000000000000000000000000000000000000000000000000e8d4a6a96c",
"owner_address": "417829b0adcb34405331a9910c646b5b71aeddc564",
"contract_address": "4155ac3875ceaf0dfe45fe3ee7312b0994a8894097"
},
"type_url": "type.googleapis.com/protocol.TriggerSmartContract"
},
"type": "TriggerSmartContract"
}],
"ref_block_bytes": "8cfc",
"ref_block_hash": "760cf585539cf343",
"expiration": 1559187525000,
"fee_limit": 1000000000,
"timestamp": 1559187465976
},
"raw_data_hex": "0a028cfc2208760cf585539cf34340889bc6b6b02d5a8e01081f1289010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412540a15417829b0adcb34405331a9910c646b5b71aeddc56412154155ac3875ceaf0dfe45fe3ee7312b0994a88940972224514fcac7000000000000000000000000000000000000000000000000000000e8d4a6a96c70f8cdc2b6b02d90018094ebdc03",
"signature": ["26dcddcbd0f5d42eb19b6628fd151061c11c7059413423a17378e2938b5001080176bf5812c451995ea070cff49b3bd43881b43bc804f08bc9d03452dba81fa801"]
}

步骤三:调用 https://api.trongrid.io/wallet/broadcasttransaction 对交易进行广播

Bodydata:

{
"txID": "83ddfa7aae3945f3aac3ef19e864e9322ae568991d377f9c4957b495d074002f",
"raw_data": {
"contract": [{
"parameter": {
"value": {
"data": "514fcac7000000000000000000000000000000000000000000000000000000e8d4a6a96c",
"owner_address": "417829b0adcb34405331a9910c646b5b71aeddc564",
"contract_address": "4155ac3875ceaf0dfe45fe3ee7312b0994a8894097"
},
"type_url": "type.googleapis.com/protocol.TriggerSmartContract"
},
"type": "TriggerSmartContract"
}],
"ref_block_bytes": "8cfc",
"ref_block_hash": "760cf585539cf343",
"expiration": 1559187525000,
"fee_limit": 1000000000,
"timestamp": 1559187465976
},
"raw_data_hex": "0a028cfc2208760cf585539cf34340889bc6b6b02d5a8e01081f1289010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412540a15417829b0adcb34405331a9910c646b5b71aeddc56412154155ac3875ceaf0dfe45fe3ee7312b0994a88940972224514fcac7000000000000000000000000000000000000000000000000000000e8d4a6a96c70f8cdc2b6b02d90018094ebdc03",
"signature": ["26dcddcbd0f5d42eb19b6628fd151061c11c7059413423a17378e2938b5001080176bf5812c451995ea070cff49b3bd43881b43bc804f08bc9d03452dba81fa801"]
}

Response:

{
"result": true
}