json-subchain-rpc
JSON is a lightweight data exchange format. It can represent numbers, strings, ordered value sequences and key-value pairs.
JSON-RPC is a stateless, lightweight Remote Procedure Call (RPC) protocol. It defines several data structures and the relevant rules to handle them. JSON-RPC is transmission-agnostic, because it can be used in situations like process, socket, HTTP, or different message transmission environments. It uses JSON(RFC 4627) as the data format.
Curl Examples Explained
The curl options below might return a response where the node complains about the content type, this is because the --data option sets the content type to application/x-www-form-urlencoded .
JSON-RPC Support
Type
Supported?
JSON-RPC 1.0
✓
JSON-RPC 2.0
✓
Batch Requests
✓
HTTP
✓
WS
✓
JSON-RPC Port
Default port:
Client
Type
Address
JSON-RPC Contents
Command
Full
Light
public
private
subchain
This RPC collection provides information of the subchain.
GetBlockCreator
This method returns the creator of a block.
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getBlockCreator","params":[int64],"id":1}
Parameters
height
:int64
- block height. Set to current block height if the given height is negative
Returns
result
:string
- the creator of the block
Example
Request
Result
GetBalanceTreeRoot
This method returns the root hash of the balance merkle tree of a block.
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getBalanceTreeRoot","params":[int64],"id":1}
Parameters
height
:int64
- block height. Set to current block height if the given height is negative
Returns
result
:string
- the root hash of the balance merkle tree
Example
Request
Result
GetTxTreeRoot
This method returns the root hash of the transaction merkle tree of a block.
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getTxTreeRoot","params":[int64],"id":1}
Parameters
height
:int64
- block height. Set to current block height if the given height is negative
Returns
result
:string
- the root hash of the transaction merkle tree
Example
Request
Result
GetBlockSignature
This method returns the signature of a block.
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getBlockSignature","params":[int64],"id":1}
Parameters
height
:int64
- block height. Set to current block height if the given height is negative
Returns
result
:string
- the signature of a block
Example
Request
Result
GetBlockInfoForStem
This method returns some information of a block including the block creator, the root hash of tx tree and the root hash of balance tree.
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getBlockInfoForStem","params":[int64],"id":1}
Parameters
height
:int64
- block height. Set to current block height if the given height is negative
Returns
result
:string
- the RLP string of [block creator, block height, the root hash of tx tree, the root hash of balance tree]
Example
Request
Result
GetTxMerkleInfo
This method returns the index and merkle proof of a transaction on the transaction merkle tree.
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getTxMerkleInfo","params":[string],"id":1}
Parameters
hexHash
:string
- hex form of a transaction hash
Returns
merkle index
:int
- the index of the input transaction at the leaf level of the transaction merkle treemerkle proof
:string
- the merkle proof of the input transaction
Example
Request
Result
GetBalanceMerkleInfo
This method returns the index and merkle proof of an account on the balance merkle tree at a given height.
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getBalanceMerkleInfo","params":[string, int64],"id":1}
Parameters
account
:string
- accountheight
:int64
- block height. Set to current block height if the given height is negative
Returns
account
:string
- accountbalance
:big.Int
- account balancemerkle index
:int
- the index of the input account at the leaf level of the balance merkle treemerkle proof
:string
- the merkle proof of the input accountnonce
:uint64
- account nonce
Example
Request
Result
GetRecentTxTreeRoot
This method returns the root hash of the recent transaction merkle tree.
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getRecentTxTreeRoot","params":[int64],"id":1}
Parameters
height
:int64
- block height. Set to current block height if the given height is negative
Returns
result
:string
- the root hash of the recent transaction merkle tree; return empty hash if this block is not a relay block
Example
Request
Result
GetRecentTxMerkleInfo
This method returns the index and merkle proof of an account on the recent transaction merkle tree at a given height.
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getRecentTxMerkleInfo","params":[string, int64],"id":1}
Parameters
account
:string
- accountheight
:int64
- block height. Set to current block height if the given height is negative
Returns
account
:string
- accountmerkle index
:int
- the index of the input account at the leaf level of the recent transaction merkle treemerkle proof
:string
- the merkle proof of the input account
Example
Request
Result
GetAccountTx
This method returns the transactions and stem signatures(used in Stem contract) of an account between two blocks(inclusive).
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getAccountTx","params":[string, int64, int64],"id":1}
Parameters
account
:string
- accountstartHeight
:int64
- start height. Set to current block height if the given height is negativeendHeight
:int64
- end height. Set to current block height if the given height is negative
Returns
account
:string
- accounttxs
:string
- the RLP string of the transaction array of the input account from startHeight to endHeightsignatures
:string
- the RLP string of the Stem signature array corresponding to the transaction array
Example
Request
Result
GetUpdatedAccountInfo
This method returns the recent updated accounts.
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getUpdatedAccountInfo","params":[int64],"id":1}
Parameters
height
:uint64
- block height
Returns
updated accounts
:string
- the RLP string of the array of recent updated accounts from height - relayInterval + 1 to heightbalances
:string
- the RLP string of the balance array corresponding to updated accounts
Example
Request
Result
GetFee
This method returns the number of verifers and their fee income given the height of relay block.
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getFee","params":[uint64],"id":1}
Parameters
height
:uint64
- block height, should be the height of a relay block
Returns
fee
:big.Int
- the fee income of each verifier from height - relayInterval + 1 to heightverNum
:big.Int
- the number of verifiers from height - relayInterval + 1 to height
Example
Request
Result
GetRelayInterval
This method returns the relay interval of the subchain.
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getRelayInterval","params":[],"id":1}
Parameters
None
Returns
Result
:uint64
- relay block interval
Example
Request
Result
Last updated