Links

mcp

The following mcp RPCs are removed comparing to Huygens as they already exist in Web3: send_block, send_offline_block, sign_msg, estimate_gas, call, account_create, account_lock, account_unlock, account_list, account_balance, account_code, logs.
And the following RPCs are newly added: epoch_approves, epoch_approve_receipts, epoch_elected_approve_receipts.
Here are the MCP RPC interfaces.

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": "s4iH1t@hBFtymA"
}

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_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_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 100.
  • 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": "0x35EAB31538EBA6CBD8E3FC1C91BFEA425EE13A1CC66B5D650A6FF226B6698A27"
}
// Failed
{
"code": 4,
"msg": "Index not found"
}

account_state_list

List all state in an account.

request fields

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

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • account_states: list of states.
  • next_index: block query index. Return null if there are no more blocks left.
{
"code": 0,
"msg": "OK",
"account_states": {
{
"hash": "0x13b10f0bf58769d28def46c83df7396012a0f693d53c1bc85a39363c14224516",
"account": "0x1144b522f45265c2dfdbaee8e324719e63a1694c",
"balance": "1999999708314231625963636182",
"nonce": "998",
"storage_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"is_alive": true
},
{
"hash": "0xf6de8683a35cf40fb183704dfc8bb3f00549d8b311c55206fdcf40cac898f548",
"account": "0x1144b522f45265c2dfdbaee8e324719e63a1694c",
"balance": "1999999708524231628405042432",
"nonce": "997",
"storage_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"is_alive": true
},
}
}

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"
}

block

Get details of one block.

request fields

  • action: block
  • hash: block hash
{
"action":"block",
"hash": "0x46bba647fb165ed3671e4c213576202fbf2a90879c30108bbfc287a9daa0ebd3"
}

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.
    • from: sender's account
    • 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.
    • gasLimit: string, uplimit of the gas for the transaction.
    • signature: signature from the sender.
// Success
{
"code": 0,
"msg": "OK",
"block": {
"hash": "0x46bba647fb165ed3671e4c213576202fbf2a90879c30108bbfc287a9daa0ebd3",
"from": "0x1144b522f45265c2dfdbaee8e324719e63a1694c",
"previous": "0x328b0837a1bf6c3ad3a8d611d9598ada10366ae459b97e714abe9af6d60932a3",
"parents": [
"0x328b0837a1bf6c3ad3a8d611d9598ada10366ae459b97e714abe9af6d60932a3"
],
"links": [
"0xb0791a6eb8772634445458dcea75e457f515cc66594a4018cef17849b43e98a1"
],
"last_summary": "0xdf492b4343a31bf1650b23358072efba776bad21889bb1d58abdb1a793c720ac",
"last_summary_block": "0xa19aeb3f80f9df34a0c29ff1c0da067f37043054ab8f624dad63e0f5140e36b2",
"last_stable_block": "0x328b0837a1bf6c3ad3a8d611d9598ada10366ae459b97e714abe9af6d60932a3",
"timestamp": 1661265734,
"gasLimit": "0x7a1200",
"signature": "0xa81cf81095d7c498778b9a6636105a74290d0d925d841da6ee4000af502e3e462ceac99504ea1a756b8958b3b3fcfd10ef67065464096f4de47fdac3fc42600600"
}
}
// 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": "0x412254AB895FD2E6ADE6F9076CA8297516F2845C989A13AC008CD5D70157AFFB"
}

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.
    • content:
      • level: the level of the block
      • witnessed_level: the witness level of the block
      • best_parent: the best parent block hash 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
      • is_on_mc: is the block on main chain.
      • is_free: does the block has children.
// Success
{
"code": 0,
"msg": "OK",
"block_state": {
"content": {
"level": 71,
"witnessed_level": 71,
"best_parent": "0x328b0837a1bf6c3ad3a8d611d9598ada10366ae459b97e714abe9af6d60932a3"
},
"is_stable": 1,
"stable_content": {
"status": 0,
"stable_index": 71,
"stable_timestamp": 1661265734,
"mci": 71,
"mc_timestamp": 1661265734,
"is_on_mc": 1,
"is_free": 0
}
}
}
// 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": [
"0x412254AB895FD2E6ADE6F9076CA8297516F2845C989A13AC008CD5D70157AFFB",
"0xB222C88AB9729B4DEF3F5E12962DB12A2FA80C9B50A4003CD67CE024428DAC61"
]
}

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": "0x412254AB895FD2E6ADE6F9076CA8297516F2845C989A13AC008CD5D70157AFFB"
}

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,
"trace_address": []
}, ...]
}
// Failed
{
"code": 1,
"msg": "Invalid hash format"
}

block_summary

Retrieve the summary for a specific block.

request fields

  • hash: block hash
{
"action": "block_summary",
"hash": "0x412254AB895FD2E6ADE6F9076CA8297516F2845C989A13AC008CD5D70157AFFB"
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message
  • summary: summary hash value.
  • previous_summary: previous summary hash value.
  • parent_summaries: parent summary hash array.
  • link_summaries: linked summary hash array.
  • skiplist_summaries: skipped summary hash array.
  • status: block state.
{
"code": 0,
"msg": "OK",
"summary": "0xb9589432747dc47c4312fdd0593995e8e1d4a159eb0bc739bd319c465198f89a",
"previous_summary": "0xbdc6c9d75fd87acf546f511b8a552b2967597247de39173896a3e437fef4b9d2",
"parent_summaries": [
"0xbdc6c9d75fd87acf546f511b8a552b2967597247de39173896a3e437fef4b9d2"
],
"link_summaries": [
"0x0000000000000000000000000000000000000000000000000000000000000000"
],
"skiplist_summaries": [],
"status": 0
}

stable_blocks

Retrieve the stabled blocks for a specific mci value.

request fields

  • action: stable_blocks.
  • limit: uplimit of the number of blocks returned. Maximum value is 100.
  • index: (optional) the index of the first block to retrieve. It can be set to be the value of next_index from the result of previous stable_blocks call. The default value is 0.
{
"action": "stable_blocks",
"limit": 100,
"index": 15577
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • blocks: the list of blocks
  • next_index:the stable index for next block. This value is null if there is no subsequent blocks.
// Success
{
"code": "0",
"msg": "OK",
"blocks": [{...}, {...}, ...],
"next_index": 15677
}
// Failed
{
"code": 1,
"msg": "Invalid hash format"
}

status

Retrieve the current status of DAG on the node

request fields

  • action:status.
{
"action": "status"
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • syncing: if the node is syncing to the other nodes,0:not syncing,1:syncing.
  • last_stable_mci: the mci of the last stable block.
  • last_mci: the mci of the last block on the main chain.
  • last_stable_block_index:the stable index of the last stable block. stable index starts from value 0 and keep increasing. It indicates the order of stable blocks on DAG.
  • epoch: the current epoch number of mcp.
  • epoch_period: the number of blocks in main chain included in each epoch.
// Success
{
"code": 0,
"msg": "OK",
"syncing": 0,
"last_stable_mci": 360,
"last_mci": 376,
"last_stable_block_index": 48367,
"epoch": 0,
"epoch_period": 100
}

peers

List the peers connected to the node.

request fields

  • action:peers.
{
"action": "peers"
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • peers: list of peers.
{
"code": 0,
"msg": "OK",
"peers": [
{
"id": "0x25680b43fc5e86e929503db9c609d95cdf3ffa5133bea37e62d1e370c80a6b5d",
"endpoint": "54.254.255.112:30612"
},
{
"id": "0x8427022566d7a2041ca60f671741872b3ed46c00e02f674d6b3ada688931bdb3",
"endpoint": "101.66.188.206:30610"
},
]
}

nodes

List the nodes connected to the node.

request fields

  • action:nodes.
{
"action": "nodes"
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • nodes: list of nodes.
{
"code": 0,
"msg": "OK",
"nodes": [
{
"id": "0x524745958eafd8a3a61ba2e9995f940441d81b3474aadbe0352d56fa84ca7079",
"endpoint": "101.66.188.202:30601"
},
{
"id": "0xccab1e8ae719a52fe76bad333e400a898a989f0538d3990a7d5712bd83e6f9bc",
"endpoint": "54.254.255.112:30611"
},
]
}

witness_list

Retrieve the list of witnesses.

request fields

  • action:witness_list。
{
"action": "witness_list"
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • witness_list:list of witnesses.
// Success
{
"code": 0,
"msg": "OK",
"witness_list": [
"0x1144B522F45265C2DFDBAEE8E324719E63A1694C"
]
}

version

Acquire the current node version, rpc interface version, and database version.

request fields

  • action:version.
{
"action": "version"
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
// Success
{
"code": 0,
"msg": "OK",
"version": "0.9.7",
"rpc_version": "1",
"store_version": "4"
}

debug_trace_transaction

Interface for debugging transaction. Returns the opcode of a transaction and the stack and memory information when it is executesd.

request fields

  • action: debug_trace_transaction.
  • hash: hash of a block.
  • options: (optional)options for debug tracing, including disable_storage (default is true) and disable_memory,disable_stack,full_storage (defaults are false).
{
"action": "debug_trace_transaction",
"hash": "9E11690B3B1CB015646ECC549A746B25E08D791E32D38363A905F2A3315C2CC1",
"options": {
"disable_storage": false
}
}

return fields

  • code: error code. The code 0 is success.
  • msg: error message.
  • gas: string, uplimit of gas usage for the transaction.
  • return_value: return value of the transaction.
  • struct_logs: traces of the transacton.
// Success
{
"code": 0,
"msg": "OK",
"gas": "1000000",
"return_value": "0x",
"struct_logs": [
{
"stack": [],
"memory": [],
"storage": {
"0x00": "0000000000000000000000000000000000000000000000000000000000000064"
},
"op": "PUSH1",
"pc": "0",
"gas": "978536",
"gasCost": "3",
"depth": "1"
},
{
"stack": [
"0000000000000000000000000000000000000000000000000000000000000080"
],
"op": "PUSH1",
"pc": "2",
"gas": "978533",
"gasCost": "3",
"depth": "1"
},
......
// Failed
{
"code": 1,
"msg": "Invalid hash"
}

debug_storage_range_at

Acquire the data in storage after executing a transaction in a contract.

request fields

  • action: debug_storage_range_at.
  • hash: block hash.
  • account: contract to debug.
  • begin: begin address of the storage to fetch data.
  • max_results: uplimit of the amount of data to fetch.
{
"action": "debug_storage_range_at",
"hash": "9E11690B3B1CB015646ECC549A746B25E08D791E32D38363A905F2A3315C2CC1",
"account": "0x1144B522F45265C2DFDBAEE8E324719E63A1694C",
"begin": "0000000000000000000000000000000000000000000000000000000000000000",
"max_results": 100
}

return fields

  • code: error code. The code 0 is success.