Links

RPC Interfaces

RPC request uses HTTP POST method. The contents in the request are in JSON format, in which the action field sepecifies the name of the RPC interface.

account_create

Create an accout. The parameter rpc_control need to be set true when run the mcp node program.

request fields

  • action:account_create
  • password:account passward
{
"action": "account_create",
"password": "[email protected]"
}

return fields

  • code:error code. The code 0 is success.
  • msg:error message.
  • account:the account created
// Success
{
"code": 0,
"msg": "OK",
"account": "0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28"
}
// Failed
{
"code": 1,
"msg": "Password can not be empty"
}

account_remove

Remove an account. The parameter rpc_control need to be true when run the mcp node program.

request fields

  • action:account_remove
  • account:account to be removed
  • password:account password
{
"action": "account_remove",
"account": "0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28",
"password": "[email protected]"
}

return fields

  • code:error code. The code 0 is success.
  • msg:error message.
// Success
{
"code": 0,
"msg": "OK"
}
// Failed
{
"code": 3,
"msg": "Wrong password"
}

account_unlock

Unlock an account. The parameter rpc_control need to be true when run the mcp node program.

request fields

  • action:account_unlock
  • account:account to be unlocked
  • password:account password
{
"action": "account_unlock",
"account": "0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28",
"password": "[email protected]"
}

return fields

  • code:error code. The code 0 is success.
  • msg:error message.
// Success
{
"code": 0,
"msg": "OK"
}
// Failed
{
"code": 3,
"msg": "Wrong password"
}

account_lock

Lock an account. The parameter rpc_control need to be true when run the mcp node program.

request fields

  • action:account_lock
  • account:account to be locked
{
"action": "account_lock",
"account": "0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28"
}

return fields

  • code:error code. The code 0 is success.
  • msg:error message.
// Success
{
"code": 0,
"msg": "OK"
}
// Failed
{
"code": 2,
"msg": "Account not found"
}

account_import

Import an account. The parameter rpc_control need to be true when run the mcp node program.

request fields

  • action:account_import
  • json:account in JSON format to be imported
{
"action": "account_import",
"json": "{\"account\":\"0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28\",\"kdf_salt\":\"175DCAF994E6992AAD1369014670C086\",\"iv\":\"F6054D9B144A254D3D4EAB78C95F21B6\",\"ciphertext\":\"2A943F3A7316C33B16374D9076FEF5BA7770C2A0424A08501D3663A1467DEDD7\"}"
}

return fields

  • code:error code. The code 0 is success.
  • msg:error message.
  • account:account imported.
// Success
{
"code": 0,
"msg": "OK",
"account": "0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28"
}
// Failed
{
"code": 2,
"msg": "Invalid json"
}

account_export

export an account.

request fields

  • action:account_export
  • account:account to be exported
{
"action": "account_export",
"account": "0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28"
}

return fields

  • code:error code. The code 0 is success.
  • msg:error message.
  • json:account in JSON format exported.
// Success
{
"code": 0,
"msg": "OK",
"json": "{\"account\":\"0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28\",\"kdf_salt\":\"37685A5B3413EC419CE4B5B79E0BB020\",\"iv\":\"F046EA90EA24A6CF0CB74BE8C560367B\",\"ciphertext\":\"4A2E6EE4CF04162D2A4DA6116C23CD94487837731055A1BC0FCBDA7E0D7C65A4\"}"
}
// Failed
{
"code": 2,
"msg": "Account not found"
}

account_validate

Validate an account.

request fields

  • action:account_validate
  • account:account to be validated
{
"action": "account_validate",
"account": "0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28"
}

return fields

  • code:error code. The code 0 is success.
  • msg:error message.
  • valid:validation results (0:invalid format,1:valid format)
// Invalid format
{
"code": 0,
"msg": "OK",
"valid": 0
}
// Valid format
{
"code": 0,
"msg": "OK",
"valid": 1
}

account_password_change

Change an account password. The parameter rpc_control need to be true when run the mcp node program.

request fields

  • action:account_password_change.
  • account:account to have password changed.
  • old_password:original password.
  • new_password:new password.
{
"action": "account_password_change",
"account": "0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28",
"old_password": "JNVRNHCK2o8N",
"new_password":"qmwevFcyebqu"
}

return fields

  • code:error code. The code 0 is success.
  • msg:error message.
// Success
{
"code": 0,
"msg": "OK"
}
// Failed
{
"code": 5,
"msg": "Wrong old password"
}

account_list

List all accounts in the node.

request fields

  • action:account_list.
{
"action": "account_list"
}

return fields

  • code:error code. The code 0 is success.
  • msg:error message.
// Success
{
"code": 0,
"msg": "OK"
"accounts": [
"0x1144B522F45265C2DFDBAEE8E324719E63A1694C",
"0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28"
]
}

account_block_list

List all blocks in an account.

request fields

  • action: account_block_list.
  • account: account to be queried for the blocks.
  • limit: uplimit of the number of returned blocks. The maximum value is 1000.
  • index:(optional)the current block query index. It should be derived from the return field next_index in the previous call of account_block_list. The default value is empty.
{
"action": "account_block_list",
"account": "0x1144B522F45265C2DFDBAEE8E324719E63A1694C",
"limit": 100
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • blocks: list of blocks.
  • next_index: block query index. Return null if there are no more blocks left.
// Success
{
"code": 0,
"msg": "OK"
"blocks": [{...}, {...}, ...],
"next_index": "35EAB31538EBA6CBD8E3FC1C91BFEA425EE13A1CC66B5D650A6FF226B6698A27"
}
// Failed
{
"code": 4,
"msg": "Index not found"
}

account_balance

Check balance of an account.

request fields

  • action:account_balance.
  • account: account to check the balance.
{
"action": "account_balance",
"account": "0x1144B522F45265C2DFDBAEE8E324719E63A1694C"
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • balance: balance of the account.
// Success
{
"code": 0,
"msg": "OK",
"balance": "1000000000000000000" // 1 CCN Token
}
// Failed
{
"code": 1,
"msg": "Invalid account"
}

accounts_balances

Check the balance of multiple accounts.

request fields

  • action:accounts_balances.
  • accounts: account to check the balance.
{
"action": "accounts_balances",
"accounts": [
"0x1144B522F45265C2DFDBAEE8E324719E63A1694C",
"0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28"
]
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • balances: balance of the accounts.
// Success
{
"code": 0,
"msg": "OK",
"balances": {
"0x1144B522F45265C2DFDBAEE8E324719E63A1694C": "1000000000000000000", //1 CCN Token
"0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28": "1000000000000000000" //1 CCN Token
}
}
// Failed
{
"code": 1,
"msg": "Invalid account"
}

account_code

Get the code of an account.

request fields

  • action:account_code.
  • account:account to get the code from.
{
"action": "account_code",
"account": "0x1144B522F45265C2DFDBAEE8E324719E63A1694C"
}

return fields

  • code:error code. The code 0 is success.
  • msg:error message.
  • account_code:account code.
// Success
{
"code": 0,
"msg": "OK",
"account_code": "61016B610030600B82828239805160001A6073146000811461002057610022565BFE5B5030600052607381538281F3FE7300000000000000000000000000000000000000003014608060405260043610610052576000357C010000000000000000000000000000000000000000000000000000000090048063DCE4A44714610057575B600080FD5B6100996004803603602081101561006D57600080FD5B81019080803573FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF169060200190929190505050610114565B6040518080602001828103825283818151815260200191508051906020019080838360005B838110156100D95780820151818401526020810190506100BE565B50505050905090810190601F1680156101065780820380516001836020036101000A031916815260200191505B509250505060405180910390F35B6060813B6040519150601F19601F602083010116820160405280825280600060208401853C5091905056FEA165627A7A7230582027C83370D70C11D17B94A12CCB8F7856B88ED68CFC6363465293981CB633B25C0029"
}
// Failed
{
"code": 1,
"msg": "Invalid account"
}

call

Get the state of a contract.

request fields

  • action: call.
  • from: (optional) source account.
  • to: destination account.
  • data: (optional) data of the call method. Default is empty.
  • mci: (optional) string. Acceptable values are "latest", "earliest" and number strings (e.g. "1352"). The default value is "latest".
{
"action":"call",
"from":"0x1144B522F45265C2DFDBAEE8E324719E63A1694C",
"to":"0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28",
"data":"0DBE671F",
"mci": "earliest"
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • output: result of the call method
// Success
{
"code": 0,
"msg": "OK",
"output": "692A70D2E424A56D2C6C27AA97D1A86395877B3A2C6C27AA97D1A86395877B5C"
}
// Failed
{
"code": 3,
"msg": "Invalid to account"
}

estimate_gas

Estimate the gas consumption of a transaction.

request fields

  • action: estimate_gas.
  • from: (optional) source account.
  • to: (optional ) destination account.
  • amount: (optional) string, amount of tokens for the transaction in the unit of 10-18 CCN.
  • gas: (optional) string, uplimit of the gas for the transaction.
  • gas_price: (optional) string, gas price in the unit of 10-18 CCN/gas. gas fee = amount of gas consumed * gas_price.
  • data: (optional) data of the transaction. The default value is empty.
  • mci: (optional) string, acceptable values are "latest", "earliest" and number strings (e.g. "1352"). The default value is "latest".
{
"action": "estimate_gas",
"from": "0x1144B522F45265C2DFDBAEE8E324719E63A1694C",
"to": "0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28",
"amount": "1000000000000000000",// 1 CCN Token
"gas": "21000",
"gas_price": "1000000000",
"data": "",
"mci": "838"
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • gas: estimated gas consumption.
// Success
{
"code": 0,
"msg": "OK",
"gas": "21000"
}
// Failed
{
"code": 9,
"msg": "Gas not enough or excute fail"
}

logs

Get the event logs of smart contract execution.

request fields

  • action: logs
  • from_stable_block_index: (optional) begin index of the stable blocks to search for. The default value is 0.
  • to_stable_block_index: (optional) end index of the stable blocks to search for. The default value is the index of the last stable block.
  • account: (optional) account to search for. The default value is empty.
  • topics: (optional) array of topics to search for. The default value is empty.
{
"action": "logs",
"account": "0x1144B522F45265C2DFDBAEE8E324719E63A1694C",
"topics":[ "260823607ceaa047acab9fe3a73ef2c00e2c41cb01186adc4252406a47d73446" ]
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • logs: arry of the logs.
// Success
{
"code": 0,
"msg": "OK",
"logs": [
{
"account": "0x1144B522F45265C2DFDBAEE8E324719E63A1694C",
"data": "0000000000000000000000000000000000000000000000000000000000000000",
"topics": [
"260823607ceaa047acab9fe3a73ef2c00e2c41cb01186adc4252406a47d73446"
]
},
{
"account": "0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28",
"data": "0000000000000000000000000000000000000000000000000000000000000001",
"topics": [
"260823607ceaa047acab9fe3a73ef2c00e2c41cb01186adc4252406a47d73446"
]
}
]
}
// Failed
{
"code": 3,
"msg": "Invalid account"
}

send_block

Send a transaction. The parameter rpc_control need to be true when run the mcp node program.

request fields

  • action: send_block.
  • previous: (optional) specify the last block hash of the sender's account. It could be used to skip the blocks in the account that are not referenced by any witnesses.
  • from: sender's account
  • to: receiver's account.
  • amount: string, amount of tokens to send in the unit of 10-18 CCN.
  • password: sender's account password.
  • gas: string, uplimit of the gas for the transaction. Unused gas fee will be returned to sender's account.
  • gas_price: string, gas price in the unit of 10-18 CCN/gas. gas fee = amount of gas consumed * gas_price.
  • data: (optional) data or smart contract code. The default value is empty.
{
"action": "send_block",
"from": "0x1144B522F45265C2DFDBAEE8E324719E63A1694C",
"to": "0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28",
"amount": "1000000000000000000",// 1 CCN Token
"password": "12345678",
"gas": "21000",
"gas_price": "1000000000",
"data": ""
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • hash: hash of the block.
// Success
{
"code": 0,
"msg": "OK",
"hash": "CDE1EC247CAC41C321024DCEBF065662A46A49A119EF0641C0547111FBCB315D"
}
// Failed
{
"code": 10,
"msg": "Wrong password"
}

send_offline_block

Send a signed transaction. The value of the request fields are derived from generate_offline_block return fields. Returns the block hash. The parameter rpc_control need to be true when run the mcp node program.

request fields

  • action:send_offline_block。
  • previous: the last block of the sender's account.
  • from: sender's account
  • to: receiver's account.
  • amount: string, amount of tokens to send in the unit of 10-18 CCN.
  • password: sender's account password.
  • gas: string, uplimit of the gas for the transaction. Unused gas fee will be returned to sender's account.
  • gas_price: string, gas price in the unit of 10-18 CCN/gas. gas fee = amount of gas consumed * gas_price.
  • data: (optional) data or smart contract code. The default value is empty.
  • signature: the signature of the block.
{
"action": "send_offline_block",
"previous": "0000000000000000000000000000000000000000000000000000000000000000",
"from": "0x1144B522F45265C2DFDBAEE8E324719E63A1694C",
"to": "0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28",
"amount": "1000000000000000000",
"gas": "21000",
"gas_price": "1000000000",
"data": "",
"signature": "71408627FF461C9DE076A38B71953A3045C95D1E1E841A2224E4AC3E503C0D0046FE8FEEB6E72B257B7743F53AFEC1CE80699D5E125C60794D6D09823C3B1E0C"
}

result fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • hash: hash of the block.
// Success
{
"code": 0,
"msg": "OK",
"hash": "93B7A0ECCE8D23E6E1969FAA5B4326CEDA78032EEB44B5F85A26AFFA84F50D64"
}
// Failed
{
"code": 1,
"msg": "Invalid from account"
}

sign_msg

sign the message.

request fields

  • action: sign_msg.
  • public_key: public key of the signature.
  • password: public key password.
  • msg: message to be signed.
{
"action":"sign_msg",
"account": "0x1144B522F45265C2DFDBAEE8E324719E63A1694C",
"password":"[email protected]",
"msg":"CB09A146D83668AE13E951032D2FD94F893C9A0CA0822ED40BBE11DC0F167D1B"
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • hash: hash of the block.
// Success
{
"code": 0,
"msg": "OK",
"signature": "E09CDD795E6959C3B85FDCA0EA56BCFBBC7BE05A0D0AB6B1A0C6DD23FF0AA36F635C70CB731DAC07909A572132128120EBC12862D4BEC2FE70E9A6060F32CA0C"
}
// Failed
{
"code": 10,
"msg": "Wrong password"
}

block

Get details of one block.

request fields

  • action: block
  • hash: block hash
{
"action":"block",
"hash": "412254AB895FD2E6ADE6F9076CA8297516F2845C989A13AC008CD5D70157AFFB"
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • block: block details. If the block doesn't exist, this field is null.
    • hash: block hash.
    • type: block type. 0:genesis block, 1:witness block, 2:ordinary block.
    • from: sender's account
    • content: block contents, which are different for blocks with different types.
      • genesisi block:
        • to: receiver's account.
        • amount: string, amount of tokens to send in the unit of 10-18 CCN.
        • data_hash: hash of the data field.
        • data: data or smart contract code.
        • timestamp: timestamp when the block is generated.
      • witness block:
        • previous: hash of the latest block of sender's account before the current block. The value is 0 for the first block of the account.
        • parents: list of the hashes of parent blocks on the DAG.
        • links: list of the hashes of the ordinary blocks that the witness block referenced.
        • last_stable_block: the last stable block of this block on the DAG.
        • last_summary_block: the last_stable_block of the best parent of this block on the DAG.
        • last_summary: the summary of last_summary_block.
        • timestamp: timestamp when the block is generated.
      • ordinary block:
        • to: receiver's account
        • amount: string, amount of tokens to send in the unit of 10-18 CCN.
        • previous: hash of the latest block of sender's account before the current block. The value is 0 for the first block of the account.
        • gas: string, uplimit of the gas for the transaction. Unused gas fee will be returned to sender's account.
        • gas_price: string, gas price in the unit of 10-18 CCN/gas. gas fee = amount of gas consumed * gas_price.
        • data_hash: hash of the data field.
        • data: data or smart contract code.
    • signature: signature from the sender.
// Success
// Witness blocks
{
"code": 0,
"msg": "OK",
"block": {
"hash": "312254FF897CA2E6ADE6F99EDAA829751481845C555A13AC008AB5D70157AEED",
"type": 1,
"from": "0x1144B522F45265C2DFDBAEE8E324719E63A1694C",
"content": {
"previous": "A5E40538D4FA7505DDE81C538AAAB97142312E3FE3D606901E2C439967FE10F0",
"parents": [
"16501EAE48B973F73CDAE418E4BD4F852EE8D11337CD9B081FF70D7FD9602283",
"AC27E98BCF2D322E36AD65561E1B65D19D31DC7695D6A243F46F25A8769DBA16"
],
"links": [
"8992AE96EE14A6138CF7E35D9EFB745751BCFA3EFA22D9032EBCC23CEDE2AA1C",
"FFE2606553075B034889E26D25FF368394C8A2FBEE7F8429AA4AEB5BD6F48EEB"
],
"last_stable_block:": "4C7F88CC9308B7A6050E6B67011C418B04BB67D5702BA43027BC1CA41BF052AD",
"last_summary_block": "77D3DE09B6418A5E28070EEB504BD84F493DD6044D2FB6DEA6260470F652EE41",
"last_summary:": "1E1A13B26AA4309DA058036A31EA5B14AC1BF227FA416844A0E34A52F20FE542",
"timestamp": 1526568538,
},
"signature": "853F9A8B9F99A8056D04AB93A03532AB7BDD164376C954FEAFCEFED698255D38984A41E1A4788C595EF83C29964DDE4E2ADEB3A21AB63E95497323FB8C9F5D03",
}
}
// Ordinary blocks
{
"code": 0,
"msg": "OK",
"block": {
"hash": "412254AB895FD2E6ADE6F9076CA8297516F2845C989A13AC008CD5D70157AFFB",
"type": 2,
"from": "mcp33EuccjKjcZgwbHYp8eLhoFiaKGARVigZojeHzySD9fQ1ysd7u",
"content": {
"to": "mcp4k1FXs5xvfYcKiikFeV3GtyMRqYMwbjatL5YVURqYf1KBgC8Mq",
"amount": "1000000000000000000", // 1 CCN Token
"previous": "A5E40538D4FA7505DDE81C538AAAB97142312E3FE3D606901E2C439967FE10F0",
"gas": "21000",
"gas_price": "1000000000"
"data_hash": "EF27E98EBD2D322E68E965561E1B65D19D31FDA595D6A243F46F57A8769DAA90",
"data": "496E204D617468205765205472757374"
},
"signature": "853F9A8B9F99A8056D04AB93A03532AB7BDD164376C954FEAFCEFED698255D38984A41E1A4788C595EF83C29964DDE4E2ADEB3A21AB63E95497323FB8C9F5D03",
}
}
// Failed
{
"code": 1,
"msg": "Invalid hash format"
}

block_state

Get state of a block

request fields

  • action: block
  • hash: block hash
{
"action":"block_state",
"hash": "412254AB895FD2E6ADE6F9076CA8297516F2845C989A13AC008CD5D70157AFFB"
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • block_state: state of the block. If the block doesn't exist, this field is null.
    • hash: block hash.
    • type: block type. 0:genesis block, 1:witness block, 2:ordinary block.
    • content: : block state contents, which are different for blocks with different types.
      • genesis block:
        • level: level of the block.
        • witnessed_level:witnessed level of the blcck.
      • witness block:
        • level: level of the block.
        • witnessed_level: witnessed level of the block
        • best_parent: the best parent of the block
      • ordinary block:
        • level: level of the block.
    • is_stable: is the block stable or not, 0:not stable,1:stable.
    • stable_content: stable block state contents. This field exists after the block is stable, and is empty if the block is not stable.
      • status: block status,0: success,1: double spending,2: invalid,3: contract execution failed.
      • stable_index: stable block index which indicates the order of blocks on DAG. The value starts from genesis block as 0, and keeps increasing.
      • mc_timestamp: main chain time stamp.
      • stable_timestamp: stable time stamp.
      • mci:main chain index
      • stable_content for different types of block:
        • genesisi block:
          • is_free: does the block has children.
          • is_on_mc: is the block on main chain.
          • from_state: hash of the sender's account state before the transaction execution.
          • to_states: hash of all the accounts' states that are updated because of the transaction execution.
          • gas_used: gas used by the transaction execution.
          • log: transaction execution log.
          • log_bloom: bloom filter of the transaction exuecution log.
        • witness block:
          • is_free: does the block has children.
          • is_on_mc: s the block on main chain.
        • ordinary block:
          • from_state: hash of the sender's account state before the transaction execution. This field is null if status of this block is 1 or 2.
          • to_states:hash of all the accounts' states that are updated because of the transaction execution. This field is null if status of this block is 1 or 2.
          • gas_used: gas used by the transaction execution. This field is null if status of this block is 1 or 2.
          • log: transaction execution log. This field is null if status of this block is 1 or 2.
          • log_bloom: bloom filter of the transaction exuecution log. This field is null if status of this block is 1 or 2.
          • contract_account: if the transaction successfully creates a new contract, this field contains the new contract address. Otherwise, it is null.
// Success
// Witness block
{
"code": 0,
"msg": "OK",
"block_state": {
"type": 1,
"content": {
"level": 245,
"witnessed_level": 224,
"best_parent": "16501EAE48B973F73CDAE418E4BD4F852EE8D11337CD9B081FF70D7FD9602283"
},
"is_stable": 1,
"stable_content": {
"status": 0,
"stable_index": 3638,
"mc_timestamp": 1526568538,
"stable_timestamp": 1526568543,
"mci": 3155,
"is_on_mc": 1,
"is_free": 0
}
}
}
// Ordinary block
{
"code": 0,
"msg": "OK",
"block_state": {
"type": 2,
"content": {
"level": 21
},
"is_stable": 1,
"stable_content": {
"status": 0,
"stable_index": 3638,
"mc_timestamp": 1526568538,
"stable_timestamp": 1526568543,
"mci": 3155,
"from_state": "DF27E98aBD2D322E688836561E1B65D19D31FDE215D6A243F46F57A8769DBB87",
"to_states": ["412254AB895FD2E6ADE6F9076CA8297516F2845C989A13AC008CD5D70157AFFB"],
"gas_used": 21000,
"log": [],
"log_bloom": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"contract_account": null
}
}
}
// Failed
{
"code": 1,
"msg": "Invalid hash format"
}

block_states

Get states of many blocks.

request fields

  • action:blocks.
  • hash: list of block hashes.
{
"action": "block_states",
"hashes": [
"412254AB895FD2E6ADE6F9076CA8297516F2845C989A13AC008CD5D70157AFFB",
"B222C88AB9729B4DEF3F5E12962DB12A2FA80C9B50A4003CD67CE024428DAC61"
]
}

result fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • blocks:list of block state contents. See block state contents in the block_state RPC method. If any of the block hashes doesn't exist, the corresponding list element is null.
// Success
{
"code": "0",
"msg": "OK",
"block_states": [{...}, null, {...}, ...]
}
// Failed
{
"code": 1,
"msg": "Invalid hash format"
}

block_traces

Get the trace of internal transactions in a smart contract.

request fields

  • action: block_traces.
  • hash: block hash.
{
"action":"block_traces",
"hash": "412254AB895FD2E6ADE6F9076CA8297516F2845C989A13AC008CD5D70157AFFB"
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • block_traces:list of block traces
    • fields in a trace:
      • type: 0:call,1:create,2:suicide。
      • action: subjective to the type of a trace
        • call: - call_type: type of call. - from: sender's account. - to: receiver's account. - gas: string,gas limit. - data: input data. - amount: string,amount in the unit of 10-18 CCN.
        • create: - from: sender's account. - gas: string,gas limit. - init: the code that creates the contract. - amount: string,amount in the unit of 10-18 CCN.
        • suicide: - contract_account: contract account. - refund_account: refund account after suicide. - balance: the total amount that is refunded in suicide.
      • result: subjective to the type of a trace. If the execution of the contract failed,this field is empty.
        • call:
          • gas_used:used gas.
          • output:output.
        • create:
          • gas_used:used gas.
          • contract_account: address of the contract created.
          • code:code of the contract created.
        • suicide:result field is null
      • error: error message. This field is null if the contract execution is successful.
      • subtraces:number of subtraces.
      • trace_address:the layer of trace.
// Success
{
"code": 0,
"msg": "OK",
"block_traces": [{
"type": 0, //call
"action": {
"call_type": "call",
"from": "0x1144B522F45265C2DFDBAEE8E324719E63A1694C",
"to": "0xa9d8863d0bf68dbaaacacad4ee0e865a0cc59f28",
"gas": "25000",
"data": "",
"amount": "120000000000000000000"
},
"result": {
"gas_used": "21000",
"output": "",
},
"subtraces":0,