Examples

This document can be referred to view two examples, that is, GetVersion and GetAccount.

GetVersion

This API returns the version of the blockchain software.

RPC Method: script.GetVersion

Returns

version: the version number

git_hash: the git commit hash of the code base

timestamp: the build timestamp

// Request

curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"script.GetVersion","params":[],"id":1}' http://localhost:16888/rpc

// Result

{

"jsonrpc": "2.0",

"id": 1,

"result": {

"version": "1.0",

"git_hash": "9d7669a735063a283ae8b6f0826183e3830c00a5",

"timestamp": "Tue Feb 19 23:31:32 UTC 2019"

}

}

GetAccount

This API returns the details of the account being queried in json format.

RPC Method: script.GetAccount

Query Parameters

address: the address of the account

Returns

code: the hash of the smart contract bytecode (for smart contract accounts)

coins: the native token balance

reserved_funds: fund reserved for micropayment through the off-chain resource-oriented payment pool

root: the root hash of the data Merkle-Patricia trie (for smart contract accounts)

sequence: the current sequence number of the account

// Request

curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"script.GetAccount","params":[{"address":"0x2E833968E5bB786Ae419c4d13189fB081Cc43bab"}],"id":1}' http://localhost:16888/rpc

// Result

{

"jsonrpc": "2.0",

"id": 1,

"result": {

"sequence": "1",

"coins": {

"SCPTWei": "0",

"SPAYWei": "4999999979999999000000000000"

},

"reserved_funds": [],

"last_updated_block_height": "0",

"root": "0x0000000000000000000000000000000000000000000000000000000000000000",

"code": "0x0000000000000000000000000000000000000000000000000000000000000000"

}

}

Last updated