To facilitate the development of the deposit scenario, the contract platform provides the native deposit interface.
NativeDepositData
deposit data on contract blockchain.
Request parameters
Encapsulate the following parameters as objects.
Parameter | Require | Type | Description |
---|---|---|---|
from | true | string | Accounts currently used for transactions. |
to | true | string | Target account of deposit. |
data | true | object | Data to be deposited. |
data
fields:
Parameter | Require | Type | Description |
---|---|---|---|
payload | true | string | Serialization of deposit data in hexadecimal type beginning with “0x”. |
Note: Deposite data is capped, and it is a configuation option of contract blockchain. It is set to 1 MB as default and you can change it to suit the situation.
Examples
chain.ctr.NativeDepositData({
from: 'Tester001',
to: 'Tester001',
data: {
payload: '0x1234' //deposit data, serialized to hexadecimal
}
}, (err, data) => {
//To query deposited data, use QueryTransaction with transaction hash.
chain.ctr.QueryTransaction({
hash: data.txhash
}, (err, data) => {
console.log('TX data:', data)
})
//Query deposited trasaction by QueryTransaction to prove the transaction executed. Use QueryTransactionReceipt can valid whether the transaction has been executed succesfully(return_code is 0) and packed into a block.
chain.ctr.QueryTransactionReceipt({
hash: data.txhash
}, (err, data) => {
console.log('Receipt data:', data)
})
})
Example
TX data: { msg_type: 62,
sequence: 4,
return_code: 0,
group_id: '0x0000000000000000000000000000000000000000',
tx:
{ hash:
'0x0c9987c9568a402e16fff5f4b2d0056ad6289a5b61109be947f1c7d25ccaf7dd',
transaction_type: 40,
timestamp: 1551861396256,
nonce: '64',
period: 100,
from:
'0xc60a9d48105950a0cca07a4c6320b98c303ad42d694a634529e8e1a0a16fcdb5',
to:
'0xc60a9d48105950a0cca07a4c6320b98c303ad42d694a634529e8e1a0a16fcdb5',
value: 0,
gas: 10000000,
group_id: '0x0000000000000000000000000000000000000000',
version: 2,
data: '0x1234',
signature:
[ '0x73a83b1e4b497222c890c9f602bb8bf48c0ed647bd8455d10b5d39886c3341ff2342a197225306ea2ac181c18ef5912fb07dd1319238469e257afa44326a9d0900' ],
extensions: [] },
block_number: 269873,
transaction_index: 0,
api: 'QueryTransaction' }
Receipt data: { msg_type: 63,
sequence: 5,
return_code: 0,
group_id: '0x0000000000000000000000000000000000000000',
receipt:
{ result: 0,
gas_used: 20020,
log_entry: [ [Object] ],
output: '' },
block_number: 269873,
transaction_index: 0,
api: 'QueryTransactionReceipt' }