Step-by-step Instructions
Step 1: triggers the smart contract to cancel transaction (acquire transaction) through the interface service provided by TronGrid
Step 2: Sign the transaction
Step 3: Broadcast the transaction
Please refer to Contract Trigger, API Signature, and Broadcasting Process for detailed documentation.
Contract Address
The base token is TRC10 and the quote token is TRX: 4155ac3875ceaf0dfe45fe3ee7312b0994a8894097
Contract Method
cancelOrder(uint256)
Parameter Description
parameter
This field is the required parameter for "cancelOrder" contract method.
cancelOrder contract method requires a parameter. This parameter is a 64-digit string.
Parameter: If the users want to cancel the order ID (acquired through the order inquiry interface), they should convert the order ID value to a hex string of numbers. If the number of digits is under 64, add "0"s to the front of the string to make up for it.
Example
User TLva2m6sx2Ya44kHUN2GZUF2PT5KcCNNUQ withdraws a TSY sell order with price of 0.54 and quantity of 20
Step 1: POST https://api.trongrid.io/wallet/triggersmartcontract to trigger contract
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"}}
Step 2: POST https://api.trongrid.io/wallet/gettransactionsign to get signature
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"]}
Step 3: POST https://api.trongrid.io/wallet/broadcasttransaction to broadcast the transaction
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}