json-subchain-rpc
Last updated
Last updated
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.
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 .
Default port:
This RPC collection provides information of the subchain.
This method returns the creator of a block.
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
This method returns the root hash of the balance merkle tree of a block.
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
This method returns the root hash of the transaction merkle tree of a block.
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
This method returns the signature of a block.
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
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.
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
This method returns the index and merkle proof of a transaction on the transaction merkle tree.
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 tree
merkle proof
: string
- the merkle proof of the input transaction
Example
Request
Result
This method returns the index and merkle proof of an account on the balance merkle tree at a given height.
Parameters
account
:string
- account
height
:int64
- block height. Set to current block height if the given height is negative
Returns
account
: string
- account
balance
: big.Int
- account balance
merkle index
: int
- the index of the input account at the leaf level of the balance merkle tree
merkle proof
: string
- the merkle proof of the input account
nonce
: uint64
- account nonce
Example
Request
Result
This method returns the root hash of the recent transaction merkle tree.
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
This method returns the index and merkle proof of an account on the recent transaction merkle tree at a given height.
Parameters
account
:string
- account
height
:int64
- block height. Set to current block height if the given height is negative
Returns
account
: string
- account
merkle index
: int
- the index of the input account at the leaf level of the recent transaction merkle tree
merkle proof
: string
- the merkle proof of the input account
Example
Request
Result
This method returns the transactions and stem signatures(used in Stem contract) of an account between two blocks(inclusive).
Parameters
account
:string
- account
startHeight
:int64
- start height. Set to current block height if the given height is negative
endHeight
:int64
- end height. Set to current block height if the given height is negative
Returns
account
: string
- account
txs
: string
- the RLP string of the transaction array of the input account from startHeight to endHeight
signatures
: string
- the RLP string of the Stem signature array corresponding to the transaction array
Example
Request
Result
This method returns the recent updated accounts.
Parameters
height
:uint64
- block height
Returns
updated accounts
: string
- the RLP string of the array of recent updated accounts from height - relayInterval + 1 to height
balances
: string
- the RLP string of the balance array corresponding to updated accounts
Example
Request
Result
This method returns the number of verifers and their fee income given the height of relay block.
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 height
verNum
: big.Int
- the number of verifiers from height - relayInterval + 1 to height
Example
Request
Result
This method returns the relay interval of the subchain.
Parameters
None
Returns
Result
: uint64
- relay block interval
Example
Request
Result
Type
Supported?
JSON-RPC 1.0
✓
JSON-RPC 2.0
✓
Batch Requests
✓
HTTP
✓
WS
✓
Client
Type
Address
Go
jsonrpc-2.0
Go
http
Go
websocket
Command
Full
Light
public
private
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
✓
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getBlockCreator","params":[int64],"id":1}
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getBalanceTreeRoot","params":[int64],"id":1}
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getTxTreeRoot","params":[int64],"id":1}
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getBlockSignature","params":[int64],"id":1}
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getBlockInfoForStem","params":[int64],"id":1}
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getTxMerkleInfo","params":[string],"id":1}
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getBalanceMerkleInfo","params":[string, int64],"id":1}
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getRecentTxTreeRoot","params":[int64],"id":1}
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getRecentTxMerkleInfo","params":[string, int64],"id":1}
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getAccountTx","params":[string, int64, int64],"id":1}
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getUpdatedAccountInfo","params":[int64],"id":1}
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getFee","params":[uint64],"id":1}
Type
Template
RPC
{"jsonrpc":"2.0","method":"subchain_getRelayInterval","params":[],"id":1}