json-rpc NV >= 1.3.0
( node version >= v1.3.0 )
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 .
Type | Supported? |
JSON-RPC 1.0 | ✓ |
JSON-RPC 2.0 | ✓ |
Batch Requests | ✓ |
HTTP | ✓ |
WS | ✓ |
Default port:
Client | Type | Address |
Go | jsonrpc-2.0 | |
Go | http | |
Go | websocket |
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
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 |
✓ | ​ | ​ | ✓ | |
✓ | ​ | ​ | ✓ | |
✓ | ​ | ​ | ✓ |
RPC collection provided for public for blockchain node and transaction manipulation.
This method returns the node information.
Type | Template |
RPC | {"jsonrpc":"2.0","method":"seele_getInfo","params":[],"id":2} |
Parameters
none
Returns
Coinbase
:string
- node addressCurrentBlockHeight
:uint64
- current block heightHeaderHash
:string
- block hashMinerStatus
:string
- miner statusShard
:int
- shard numberVersion
:string
- version number of the nodeBlockAge
:big.Int
- the age of the latest block of the nodePeerCnt
:string
- total peer count and the peer count of each shard
Example
- Request
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_getInfo","params":[],"id":1}' localhost:8037
- Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"Coinbase": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21",
"CurrentBlockHeight": 1759971,
"HeaderHash": "0x64ac24b6463d2cf14b9fd8b1c38ea6347977b38f105f76e34baf24fcc46f6aaf",
"Shard": 1,
"MinerStatus": "Stopped",
"Version": "v1.2.7",
"BlockAge": -5,
"PeerCnt": "11 (2 3 3 3)"
}
}
This method returns the account balance given the account address.
Type | Template |
RPC | {"jsonrpc":"2.0","method":"seele_getBalance","params":[string,string ,uint64],"id":1} |
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 balance
Returns
Account
:string
- accountBalance
:big.Int
- account balance
Example
- Request
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_getBalance","params":["0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21","",-1],"id":1}' localhost:8037
- Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"Account": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21",
"Balance": 265499990000
}
}
This method submits a transaction to the node.
Type | Template |
RPC | {"jsonrpc":"2.0","method":"seele_addTx","params":[types.Transaction],"id":1} |
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 structtype Signature struct {Sig []byte // [R || S || V] format signature in 65 bytes.}
Returns
result
:bool
- transaction send result
Example
- Request
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_addTx","params":[{"Hash": "0x3393e5566cb905d714599f2f888ecc6d223b83403887460fa5b2771e89a0436e","Data": {"From": "0x3b691130ec4166bfc9ec7240217fc8d08903cf21","To":"0x2a87b6504cd00af95a83b9887112016a2a991cf1","Amount": 1,"AccountNonce":0,"Fee": 0,"GasPrice":10, "GasLimit":21000},"Signature":{"Sig":"fAvgVTXDyJZbfv07NYBK4aSolfY4ycBPQRwnQFpHRMc7ooOZw27U50o4TBoRelYX3QCRyvKpbxVlxhu7AnSB6QE="}}],"id":1}' localhost:8037
- Result
{
"jsonrpc": "2.0",
"id": 1,
"result": true
}
This method is used to obtain the account nonce.
Type | Template |
RPC | {"jsonrpc":"2.0","method":"seele_getAccountNonce","params":[string,string ,uint64],"id":1} |
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 nonce
Returns
result
:uint64
- account nonce
Example
- Request
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_getAccountNonce","params":["0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21","",-1],"id":1}' localhost:8037
- Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 3
}
This method is used to obtain the height of the blockchain.
Type | Template |
RPC | {"jsonrpc":"2.0","method":"seele_getBlockHeight","params":[],"id":1} |
Parameters
none
Returns
result
:uint64
- block height
Example
- Request
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_getBlockHeight","params":[],"id":1}' localhost:8037
- Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 1928
}
This method is used to obtain the block content based on block height or block hash.
Type | Template |
RPC | {"jsonrpc":"2.0","method":"seele_getBlock","params":[string,string,bool],"id":1} |
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
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_getBlock","params":["",19018,true],"id":1}' localhost:8037
- Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"debts": [],
"hash": "0x000002f75910694bf33a9a2f3e0cab454ac4b14ff9d32aee7b59efc20260f00c",
"header": {
"PreviousBlockHash": "0x000005f39610211ad1e888940a0e6affb538ea2397f73e08f1f894537997118c",
"Creator": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21",
"StateHash": "0xde119fb11c8c74b34a71ce376589a1711af5acef99aaf36827fbaafaeb9fe617",
"TxHash": "0xa5dea280e6e880af7547ffea5c54526b0a3fae9dcd977a0a5a00e14852eb08ce",
"ReceiptHash": "0xd6efdf2db85d6a5ab3fdc14925f67b9c97fb7ebdb733e5b2bb5776c694bc9073",
"TxDebtHash": "0x8fde2b990967a9e51cb5218acc3318faea7a50429760cef37867b12c62f30b78",
"DebtHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"Difficulty": 2258387,
"Height": 19018,
"CreateTimestamp": 1548821456,
"Witness": "MTI4ODU5Njk2MTcyODI5NzQ3MzM=",
"Consensus": 0,
"ExtraData": ""
},
"totalDifficulty": 52970343102,
"transactions": [
{
"accountNonce": 0,
"amount": 1200000000,
"from": "0x0000000000000000000000000000000000000000"