All Products
Search
Document Center

Blockchain as a Service:Data Model

Last Updated:May 22, 2019

In JS SDK, many data structures are consistent with those of the contract platform, including accounts, contracts, blocks, transactions, and receipts.

Account model

Basic account parameters are described as follows:

Name Type Description
identity string The identity of the account. It is a hexadecimal string.
balance BigNumber. It is a special type. For more information, see Details The balance.
auth_map string The public key and weight value of an account or a smart contract.
recover_key string The recovery public key that is used when the private key is lost. It is a hexadecimal string.
recover_time number The last recovery time.
status number The status of the account. 0: NORMAL. 1: FREEZE. 2: RECOVERING.
encryption_key string The public key that is used to encrypt the transaction amount in a smart contract. It is a hexadecimal string.

Examples

  1. { identity:
  2. '0xc60a9d48105950a0cca07a4c6320b98c303ad42d694a634529e8e1a0a16fcdb5',
  3. balance: 1000000000000000000,
  4. recover_key:
  5. '0x61df14a4625bd997eeae2ebcffe58aa95ab3fcd1d7660f83b5fe34a6e08915beae36d84f960f6baca008b67c919feae0f29c262b43e985b477f92626ed2b6f6a',
  6. recover_time: 0,
  7. status: 0,
  8. code: '',
  9. storage_root:
  10. '0x76be8b528d0075f7aae98d6fa57a6d3c83ae480a8469e668d7b0af968995ac71',
  11. code_hash:
  12. '0x0000000000000000000000000000000000000000000000000000000000000000',
  13. encryption_key: '',
  14. version: '2',
  15. auth_map:
  16. [ { auth_key:
  17. '0x61df14a4625bd997eeae2ebcffe58aa95ab3fcd1d7660f83b5fe34a6e08915beae36d84f960f6baca008b67c919feae0f29c262b43e985b477f92626ed2b6f6a',
  18. auth_weight: 100 } ] }

Contract model

Basic contract parameters are described as follows:

Name Type Description
identity string The identity of the contract. It is a hexadecimal string.
balance BigNumber. It is a special type. For more information, see Details The balance.
auth_map string The public key and weight value of an account or a smart contract.
recover_key string The recovery public key that is used when the private key is lost. It is a hexadecimal string.
recover_time number The last recovery time.
status number The status of the contract. 0: NORMAL. 1: FREEZE. 2: RECOVERING.
encryption_key string The public key that is used to encrypt the transaction amount in a smart contract. It is a hexadecimal string.
storage_root string The root node hash of the Merkle tree in the world state. It is a hexadecimal string.
code_hash string The contract code hash. It is a hexadecimal string.
code string The contract code. It is a hexadecimal string.

Examples

  1. { identity:
  2. '0xe784481df592b4f72360db588d04fc55c4fa800c867a1ca7bb9f470ddf805b6d',
  3. balance: 0,
  4. recover_key:
  5. '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
  6. recover_time: 0,
  7. status: 0,
  8. code:
  9. '0x016080604052600436106100825763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630d15fd7781146100875780632f265cf7146100ae578063392e6678146100dc5780637021939f14610108578063a9a981a314610120578063b13c744b14610135578063cc9ab2671461014d575b600080fd5b34801561009357600080fd5b5061009c610167565b60408051918252519081900360200190f35b3480156100ba57600080fd5b506100c660043561016d565b6040805160ff9092168252519081900360200190f35b3480156100e857600080fd5b506100f4600435610199565b604080519115158252519081900360200190f35b34801561011457600080fd5b506100c660043561024e565b34801561012c57600080fd5b5061009c610263565b34801561014157600080fd5b5061009c600435610269565b34801561015957600080fd5b50610165600435610288565b005b60035481565b600061017882610199565b151561018357600080fd5b5060009081526001602052604090205460ff1690565b6000805b60005481101561020f5760008054849190839081106101b857fe5b600091825260209091200154141561020757604080516001815290517f2b766bfa48dbb99822ac647fffc163dc74b7857beedb5ec6782ed9826453db049181900360200190a160019150610248565b60010161019d565b604080516000815290517f2b766bfa48dbb99822ac647fffc163dc74b7857beedb5ec6782ed9826453db049181900360200190a1600091505b50919050565b60016020526000908152604090205460ff1681565b60025481565b600080548290811061027757fe5b600091825260209091200154905081565b61029181610199565b151561029c57600080fd5b600081815260016020818152604092839020805460ff80821685011660ff19909116179055600380549092019091558151838152339181019190915281517f690156027e055e69a001816111c1abd4287fa897e929662c9ad6108a84fe2523929181900390910190a1505600a165627a7a72305820f4f856c692cb5ff1f3f493855d83e03251ad0399970bdf9119597e2593fd68d00029',
  10. storage_root:
  11. '0xd76c14b0f7f99cd297110d1d711a56a70d0ee758174e957874d3354dfb6fc5f4',
  12. code_hash:
  13. '0xf2798023afd1207ca4ac57ad2ecb84b032b0279d27294a6e2c57dfffb3eadeb5',
  14. encryption_key: '',
  15. acc_version: 2,
  16. auth_map:
  17. [ { auth_key:
  18. '0x61df14a4625bd997eeae2ebcffe58aa95ab3fcd1d7660f83b5fe34a6e08915beae36d84f960f6baca008b67c919feae0f29c262b43e985b477f92626ed2b6f6a',
  19. auth_weight: 100 } ] }

Transaction model

Basic transaction parameters are described as follows:

Name Type Description
hash string The transaction hash composed of all fields excluding the signature field.
type number The type of the transaction.
timestamp number The timestamp of the transaction.
nonce number Prevents replay attacks.
period number The time in milliseconds when the transaction starts or ends.
from string The sender of the transaction.
to string The recipient of the transaction.
value number The transferred amount.
gas number The transaction fee paid by the source account for a transaction.
data string For more information, see the data encoding methods of the transaction object.
group_id string The ID of the group where the transaction is executed.
signature string The signature. Signs the hash using one or multiple private keys.
extensions string The transaction extension field. It is currently not supported by JS SDK.

Receipt model

Basic receipt parameters are described as follows:

Name Type Description
result number The transaction result.
gas_used number The transaction fee paid by the source account for a transaction.
logs Array The log entries of transaction executions.
output BigNumber The output of the contract.
offset number The offset of the contract output.

Log model

Basic log parameters are described as follows:

Name Type Description
from string The sender of the transaction.
to string The recipient of the transaction.
topics Array The subscribed topics.
log_data Array The log data generated by the transaction.

Block model

The block model is divided into three parts: block, block header, and block body.

  • Basic block parameters are described as follows:
Name Type Description
block_header object The block header.
block_body object The block body.
  • Basic parameters of block_header are described as follows:
Name Type Description
hash string The hash of the block header.
version number The version of the block header.
number number The block number.
parent_hash string The previous block hash.
transaction_root string The root node hash of the Merkle tree generated by the transactions in the block body.
receipt_root string The root node hash of the Merkle tree generated by the receipts in the block body.
state_root string The root node hash of the Merkle tree in the world state.
gas_used number The total gas consumed by transactions.
timestamp number The timestamp.
log_bloom string The log bloom filter.
  • Basic parameters of block_body are described as follows:
Name Type Description
transaction_list Array The transaction list.
receipt_list Array The receipt list.
consensus_proof string The consensus proof.

Examples

  1. block:
  2. { block_header:
  3. { hash:
  4. '0xf3f53c5ec6ede0bd24a2e36914cd5fbc3c2a7de80d677efdd704459a7f5f9879',
  5. version: 2,
  6. block_number: 86117,
  7. parent_hash:
  8. '0xe252fe8333dce2bacc9ec1764d03b41dea30cc0f02d3064dc2537f0db63110b8',
  9. transaction_root:
  10. '0x0000000000000000000000000000000000000000000000000000000000000000',
  11. receipt_root:
  12. '0x0000000000000000000000000000000000000000000000000000000000000000',
  13. state_root:
  14. '0xb849f08a17fd0cdd97b14c3531f18d9c82b9411ad9e97bc8812f05349496aa30',
  15. gas_used: 0,
  16. timestamp: 1547388041992,
  17. log_bloom:
  18. '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' },
  19. block_body:
  20. { transaction_list: [],
  21. receipt_list: [],
  22. consensus_proof:
  23. '0xf8f2f8c9b84154f46c7c6a4bd7b4da1350de36d6b7cd24e595d82b6cbc93c8b161a653e9a9db25e9aad5ed219873a44ba86dd812df0ff0813840af198703eedd2446517d761f01b841563d53272fa6627a32192f28747e1cffd541a3da206fa7f788311e30fcc0272d2c65982f341be4e9a9d8a0139e1b346b8ca835a3f710a58a00bb1f52ae7cba5b01b841db26385c9d5e8f2759c5ac72dc90befd3e2a0b6ad0ac25bd7ea0737025c07a776d34fb84625dce19d8c82450205034737414ed14999fbfa28653ee62547bd77201e61e83015065a048c1edc05bc2f69c32e61b6a79b39880474bf23fdb2466a0de3a88cdae42c649' }
  24. }