json-rpc NV <= 1.2.7
( node version <= v1.2.7 )
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 |
Go | jsonrpc-2.0 | |
Go | http | |
Go | websocket |
JSON-RPC List
Currently, there are several RPCs with different namespaces:
seele
:node data manipulation and procurement / acquisitiontxpool
:transaction pool managementdownload
:RPC collection provided for internal inquiry of blockchain node synchronization state.network
:connection managementminer
:miner manipulationdebug
:node debuggingmonitor
:node monitor
JSON-RPC Contents
Command | Full | Light | public | private |
✓ | ✓ | |||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | |||
✓ | ✓ | |||
✓ | ✓ | |||
✓ | ✓ |
Command | Full | Light | public | private |
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ |
Command | Full | Light | public | private |
✓ | ✓ |
Command | Full | Light | public | private |
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ |
Command | Full | Light | public | private |
✓ | ✓ | |||
✓ | ✓ | |||
✓ | ✓ | |||
✓ | ✓ | |||
✓ | ✓ | |||
✓ | ✓ | |||
✓ | ✓ | |||
✓ | ✓ |
Command | Full | Light | public | private |
✓ | ✓ | |||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | ✓ | ||
✓ | ✓ | |||
✓ | ✓ | |||
✓ | ✓ |
seele
RPC collection provided for public for blockchain node and transaction manipulation.
GetInfo
This method returns the node information.
Type | Template |
RPC |
|
Parameters
none
Returns
Coinbase
:string
- node addressCurrentBlockHeight
:uint64
- current block heightHeaderHash
:string
- block hashMinerStatus
:string
- miner statusShard
:int
- shard number
Example
Request
Result
GetBalance
This method returns the account balance give the account address.
Type | Template |
RPC |
|
Parameters
Account
:string
- accounthexHash
:string
- hex form of a block hash, set to "" for the latest balanceheight
:uint64
- height of a block, set to -1 for the latest balanceReturns
Account
:string
- accountBalance
:big.Int
- account balance
Example
Request
Result
AddTx
This method submits a transaction to the node.
Type | Template |
RPC |
|
Parameters
tx
:types.Transaction
- transaction struct (client commandsign
could be used to get transaction hash and signature)Hash
:string
- transaction hashData
:json
- transaction dataFrom
:string
- transaction senderTo
:string
- transaction receiverAmount
:uint64
- amount value, unit is fanFee
:uint64
- transaction feePayload
:string
- transaction payloadAccountNonce
:uint64
- transaction nonce
Signature
:crypto.Signature
- transaction signature struct
Returns
result
:bool
- transaction send result
Example
Request
Result
GetAccountNonce
This method is used to obtain the account nonce.
Type | Template |
RPC |
|
Parameters
account
:string
- accounthexHash
:string
- hex form of a block hash, set to "" for the latest nonceheight
:uint64
- height of a block, set to -1 for the latest nonceReturns
result
:uint64
- account nonce
Example
Request
Result
GetBlockHeight
This method is used to obtain the height of the blockchain.
Type | Template |
RPC |
|
Parameters
none
Returns
result
:uint64
- block height
Example
Request
Result
GetBlock
This method is used to obtain the block content based on block height or block hash.
Type | Template |
RPC |
|
Parameters
hash
:string
- block hashheight
:string
- block heightfulltx, f
:bool
- whether to include detailed transaction information
Returns
debts
:array
- debts in blockHash
:string
- debts hashData
:json
- debts dataTxHash
:string
- txhash in debtShard
:int
- shard number of seele node where debts onAccount
:array
- debt accountAmount
:int64
- debt amountFee
:int64
- debt feeCode
:string
- debt code
hash
:string
- block hashheader
:json
- block headerPreviousBlockHash
:string
- previous block hashCreator
:string
- creator addressTxHash
:string
- tx hashReceiptHash
:string
- Receipts hashstateHash
:string
- state tree hashTxDebtHash
:string
- debts hashDebtHash
:string
- debts hashDifficulty
:big.Int
- block difficultyHeight
:unit64
- block heightCreateTimestamp
:uint64
- create timestampWitness
:string
- block nonceConsensus
:int
- consensus algorithmExtraData
:string
- extra data
totalDifficulty
:big.Int
- total difficultytransactions
:array
- transaction arrayaccountNonce
:unit64
- account nonceamount
:Int
- transaction amountfrom
:string
- transaction providergasLimit
:Int
- transaction gas limitgasPrice
:Int
- transaction gas pricehash
:string
- transaction hashpayload
:array
- transaction payloadto
:string
- transaction receiver
txDebts
:array
- transaction debtsHash
:string
- txDebts hashData
:json
- txDebts dataTxHash
:string
- transaction hashFrom
:string
- transaction senderNonce
:unit64
- sender nonceAccount
:string
- transaction accountAmount
:int
- transaction amountPrice
:int
- transaction gas priceCode
:string
- transaction code
Example
Request
Result
GetBlockByHash
This method is used to obtain the block content based on block hash.
Type | Template |
RPC |
|
Parameters
hash
:string
- block hashfulltx, f
:bool
- whether to include detailed transaction information
Returns
debts
:array
- debts in blockHash
:string
- debts hashData
:json
- debts dataTxHash
:string
- txhash in debtShard
:int
- shard number of seele node where debts onAccount
:array
- debt accountAmount
:int64
- debt amountFee
:int64
- debt feeCode
:string
- debt code
hash
:string
- block hashheader
:json
- block headerPreviousBlockHash
:string
- previous block hashCreator
:string
- creator addressTxHash
:string
- tx hashReceiptHash
:string
- Receipts hashstateHash
:string
- state tree hashTxDebtHash
:string
- debts hashDebtHash
:string
- debts hashDifficulty
:big.Int
- block difficultyHeight
:unit64
- block heightCreateTimestamp
:uint64
- create timestampWitness
:string
- block nonceConsensus
:int
- consensus algorithmExtraData
:string
- extra data
totalDifficulty
:big.Int
- total difficultytransactions
:array
- transaction arrayaccountNonce
:unit64
- account nonceamount
:Int
- transaction amountfrom
:string
- transaction providergasLimit
:Int
- transaction gas limitgasPrice
:Int
- transaction gas pricehash
:string
- transaction hashpayload
:array
- transaction payloadto
:string
- transaction receiver
txDebts
:array
- transaction debtsHash
:string
- txDebts hashData
:json
- txDebts dataTxHash
:string
- transaction hashFrom
:string
- transaction senderNonce
:unit64
- sender nonceAccount
:string
- transaction accountAmount
:int
- transaction amountPrice
:int
- transaction gas priceCode
:string
- transaction code
Example
Request
Result
GetBlockByHeight
This method is used to obtain the block content based on block height.
Type | Template |
RPC |
|
Parameters
height
:string
- block heightfulltx, f
:bool
- whether to include detailed transaction information
Returns
debts
:array
- debts in blockHash
:string
- debts hashData
:json
- debts dataTxHash
:string
- txhash in debtShard
:int
- shard number of seele node where debts onAccount
:array
- debt accountAmount
:int64
- debt amountFee
:int64
- debt feeCode
:string
- debt code
hash
:string
- block hashheader
:json
- block headerPreviousBlockHash
:string
- previous block hashCreator
:string
- creator addressTxHash
:string
- tx hashReceiptHash
:string
- Receipts hashstateHash
:string
- state tree hashTxDebtHash
:string
- debts hashDebtHash
:string
- debts hashDifficulty
:big.Int
- block difficultyHeight
:unit64
- block heightCreateTimestamp
:uint64
- create timestampWitness
:string
- block nonceConsensus
:int
- consensus algorithmExtraData
:string
- extra data
totalDifficulty
:big.Int
- total difficultytransactions
:array
- transaction arrayaccountNonce
:unit64
- account nonceamount
:Int
- transaction amountfrom
:string
- transaction providergasLimit
:Int
- transaction gas limitgasPrice
:Int
- transaction gas pricehash
:string
- transaction hashpayload
:array
- transaction payloadto
:string
- transaction receiver
txDebts
:array
- transaction debtsHash
:string
- txDebts hashData
:json
- txDebts dataTxHash
:string
- transaction hashFrom
:string
- transaction senderNonce
:unit64
- sender nonceAccount
:string
- transaction accountAmount
:int
- transaction amountPrice
:int
- transaction gas priceCode
:string
- transaction code
Example
Request
Result
Call
This method is used to execute a given transaction on a statedb of a given block height. It does not affect the statedb or blockchain and is useful for executing and retrieving values. However, the height currently does not support optional and will remove the from parameter in the next version or more.
Type | Template |
RPC |
|
Parameters
to
:string
- to addresspayload
:string
- transaction payload infoHeight
:int64
- block height (default: -1)
Returns
contract
:string
- contract addressfailed
:bool
- contract executes successfully or notpoststate
:string
- state trie root hash after transaction executionresult
:string
- transaction resulttotalFee
:int64
- transaction feetxhash
:string
- transaction hashusedGas
:int64
- transaction gas
Example
When using the example below, the contract must be deployed first. The solidity code file:
As you can see, the example is testing the get function.
Request
Result
GetLogs
This method gets the event logs by block height, the contract address, and the event name.
Type | Template |
RPC |
|
Parameters
height
:int64
- block height (default: -1)contract
:string
- contract addressabi
:string
- contract abievent
:string
- event name
Returns
address
:string
- contract addresstopics
:array
- topic arraydata
:string
- datablocknumber
:uint64
- block heighttransactionNumber
:uint
- the index of the transaction in the block
Example
When using the example below, the contract must be deployed first. The solidity code file:
As you can see, this example is testing the get function. In this situation, the height is the block height of the block containing the get transaction.
Request
Result
GeneratePayload
This method generate the contract method payload.
Type | Template |
RPC |
|
Parameters
abiJSON
:string
- contract json stringmethodName
:string
- contract method nameargs
:string
- args of contract method
Returns
result
:string
payload of contract method with args
Example
Request
Result
EstimateGas
This method Estimate the gas of a transaction.
Type | Template |
RPC |
|
Parameters
Hash
:string
- transaction hashData
:json
- transaction dataFrom
:string
- transaction senderTo
:string
- transaction receiverAmount
:uint64
- amount value, unit is fanGasPrice
:uint64
- transaction gas price in FanGasLimit
:uint64
- maximum gas for transactionPayload
:string
- transaction payloadAccountNonce
:uint64
- transaction nonce
Returns
result
:uint64 - gas amount
Example
Request
Result
txpool
RPC collection provided for internal use for transaction pool inquiry manipulation.
GetBlockTransactionCount
This method is used to obtain the number of transactions in the transaction pool based on block height or hash.
Type | Template |
RPC |
|
Parameters
hash
:string
- hash value in hexheight
:int64
- block height (default: -1)
Returns
result
:int
- transactions count
Example
Request
Result
GetBlockTransactionCountByHeight
This method is used to obtain the number of transactions in the transaction pool based on block height.
Type | Template |
RPC |
|
Parameters
height
:int64
- block height (default: -1)
Returns
result
:int
- transactions count
Example
Request
Result
GetBlockTransactionCountByHash
This method is used to obtain the number of transactions in the transaction pool based on block hash.
Type | Template |
RPC |
|
Parameters
hash
:string
- hash value in hex
Returns
result
:int
- transactions count
Example
Request
Result
GetTransactionByBlockIndex
This method is used to obtain the transaction content based on block height or hash and transaction index.
Type | Template |
RPC |
|
Parameters
hash
:string
- block hashheight
:int
- block height (default: -1)index
:int
- transaction index, start with 0 (default: 0)
Returns
accountNonce
:unit64
- account nonceamount
:Int
- transaction amountgasLimit
:Int
- transaction gas limitgasPrice
:Int
- transaction gas pricefrom
:string
- transaction providerto
:string
- transaction receiverhash
:string
- transaction hashpayload
:array
- transaction payload
Example
Request
Result
GetTransactionByBlockHeightAndIndex
This method is used to obtain the transaction content based on block height and transaction index.
Type | Template |
RPC |
|
Parameters
height
:int
- block height (default: -1)index
:int
- transaction index, start with 0 (default: 0)
Returns
accountNonce
:unit64
- account nonceamount
:Int
- transaction amountgasLimit
:Int
- transaction gas limitgasPrice
:Int
- transaction gas pricefrom
:string
- transaction providerto
:string
- transaction receiverhash
:string
- transaction hashpayload
:array
- transaction payload
Example
Request
Result
GetTransactionByBlockHashAndIndex
This method is used to obtain the transaction content based on block hash and transaction index.
Type | Template |
RPC |
|
Parameters
hash
:string
- block hashindex
:int
- transaction index, start with 0 (default: 0)
Returns
accountNonce
:unit64
- account nonceamount
:Int
- transaction amountgasLimit
:Int
- transaction gas limitgasPrice
:Int
- transaction gas pricefrom
:string
- transaction providerto
:string
- transaction receiverhash
:string
- transaction hashpayload
:array
- transaction payload
Example
Request
Result
GetTransactionByHash
This method returns transaction information by hash.
Type | Template |
RPC |
|
Parameters
hash
:string
- hash value in hex
Returns
blockHash
:string
- block hashblockHeight
:int
- block heightstatus
:string
- transaction statusaccountNonce
:unit64
- account nonceamount
:Int
- transaction amountgasLimit
:Int
- transaction gas limitgasPrice
:Int
- transaction gas pricefrom
:string
- transaction providerto
:string
- transaction receiverhash
:string
- transaction hashpayload
:array
- transaction payloadtxIndex
:int
- transaction index in block
Example
Request
Result
GetReceiptByTxHash
This method is used to obtain the receipt contents based on transaction hash.
Type | Template |
RPC |
|
Parameters
hash
:string
- hash value in hexabi
:string
- the abi file of contract
Returns
contract
:string
- contract addressfailed
:bool
- transaction executes successfully or notpoststate
:string
- state trie root hash after transaction executionresult
:string
- transaction resulttotalFee
:int
- transaction feetxhash
:string
- transaction hashusedGas
:int
- transaction gas
Example
Request
Result
GetDebtByHash
This method is used to obtain the debt contents based on debt hash.
Type | Template |
RPC |
|
Parameters
hash
:string
- debt hash value in hex
Returns
blockHash
:string
- block hash of the debt onblockHeight
:int64
- block height of the debt ondebt
:json
- debt jsonHash
:string
- debt hashData
:json
- debt dataTxHash
:string
- txhash in debtFrom
:string
- address of the senderNonce
:uint64
- nonce of From addressAccount
:string
- debt accountAmount
:int64
- debt amountPrice
:int64
- debt priceCode
:string
- debt contract code
debtIndex
:int
- debt index of the block debtsstatus
:string
- debt status
Example
Request
Result
download
RPC collection provided for internal inquiry of blockchain node synchronization state.
GetStatus
This method returns synchronization information.
Type | Template |
RPC |
|
Parameters
none
Returns
Status
:string
- synchronization stateDuration
:string
- synchronization duration (seconds)StartNum
:uint64
- synchronization initial block heightAmount
:uint64
- synchronization valueDownloaded
:uint64
- Synchronization number of times
Example