All Products
Search
Document Center

Native Deposit Interface

Last Updated: May 24, 2019

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

  1. chain.ctr.NativeDepositData({
  2. from: 'Tester001',
  3. to: 'Tester001',
  4. data: {
  5. payload: '0x1234' //deposit data, serialized to hexadecimal
  6. }
  7. }, (err, data) => {
  8. //To query deposited data, use QueryTransaction with transaction hash.
  9. chain.ctr.QueryTransaction({
  10. hash: data.txhash
  11. }, (err, data) => {
  12. console.log('TX data:', data)
  13. })
  14. //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.
  15. chain.ctr.QueryTransactionReceipt({
  16. hash: data.txhash
  17. }, (err, data) => {
  18. console.log('Receipt data:', data)
  19. })
  20. })

Example

  1. TX data: { msg_type: 62,
  2. sequence: 4,
  3. return_code: 0,
  4. group_id: '0x0000000000000000000000000000000000000000',
  5. tx:
  6. { hash:
  7. '0x0c9987c9568a402e16fff5f4b2d0056ad6289a5b61109be947f1c7d25ccaf7dd',
  8. transaction_type: 40,
  9. timestamp: 1551861396256,
  10. nonce: '64',
  11. period: 100,
  12. from:
  13. '0xc60a9d48105950a0cca07a4c6320b98c303ad42d694a634529e8e1a0a16fcdb5',
  14. to:
  15. '0xc60a9d48105950a0cca07a4c6320b98c303ad42d694a634529e8e1a0a16fcdb5',
  16. value: 0,
  17. gas: 10000000,
  18. group_id: '0x0000000000000000000000000000000000000000',
  19. version: 2,
  20. data: '0x1234',
  21. signature:
  22. [ '0x73a83b1e4b497222c890c9f602bb8bf48c0ed647bd8455d10b5d39886c3341ff2342a197225306ea2ac181c18ef5912fb07dd1319238469e257afa44326a9d0900' ],
  23. extensions: [] },
  24. block_number: 269873,
  25. transaction_index: 0,
  26. api: 'QueryTransaction' }
  27. Receipt data: { msg_type: 63,
  28. sequence: 5,
  29. return_code: 0,
  30. group_id: '0x0000000000000000000000000000000000000000',
  31. receipt:
  32. { result: 0,
  33. gas_used: 20020,
  34. log_entry: [ [Object] ],
  35. output: '' },
  36. block_number: 269873,
  37. transaction_index: 0,
  38. api: 'QueryTransactionReceipt' }