Skip to content

JSON RPC

xiaopeng edited this page Dec 31, 2019 · 1 revision

Contents

JSON RPC API

JSON is a lightweight data-interchange format. It can represent numbers, strings, ordered sequences of values, and collections of name/value pairs.

JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. Primarily this specification defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over HTTP, or in many various message passing environments. It uses JSON (RFC 4627) as data format.

JavaScript API

To talk to an vnscoin node from inside a JavaScript application use the web3.js library, which gives a convenient interface for the RPC methods. See the JavaScript API for more.

JSON-RPC Endpoint

Default JSON-RPC endpoints:

Client URL
Go http://localhost:8585

Go

You can start the HTTP JSON-RPC with the --rpc flag

./gvns --rpc

change the default port (8585) and listing address (localhost) with:

./gvns --rpc --rpcaddr <ip> --rpcport <portnumber>

If accessing the RPC from a browser, CORS will need to be enabled with the appropriate domain set. Otherwise, JavaScript calls are limit by the same-origin policy and requests will fail:

./gvns --rpc --rpccorsdomain "http://localhost:3000"

The JSON RPC can also be started from the gvnsconsole using the admin.startRPC(addr, port) command.

JSON-RPC support

JSON-RPC 1.0 JSON-RPC 2.0 Batch requests HTTP IPC WS
go-vnscoin

HEX value encoding

At present there are two key datatypes that are passed over JSON: unformatted byte arrays and quantities. Both are passed with a hex encoding, however with different requirements to formatting:

When encoding QUANTITIES (integers, numbers): encode as hex, prefix with "0x", the most compact representation (slight exception: zero should be represented as "0x0"). Examples:

  • 0x41 (65 in decimal)
  • 0x400 (1024 in decimal)
  • WRONG: 0x (should always have at least one digit - zero is "0x0")
  • WRONG: 0x0400 (no leading zeroes allowed)
  • WRONG: ff (must be prefixed 0x)

When encoding UNFORMATTED DATA (byte arrays, account addresses, hashes, bytecode arrays): encode as hex, prefix with "0x", two hex digits per byte. Examples:

  • 0x41 (size 1, "A")
  • 0x004200 (size 3, "\0B\0")
  • 0x (size 0, "")
  • WRONG: 0xf0f0f (must be even number of digits)
  • WRONG: 004200 (must be prefixed 0x)

The default block parameter

The following methods have an extra default block parameter:

When requests are made that act on the state of vnscoin, the last default block parameter determines the height of the block.

The following options are possible for the defaultBlock parameter:

  • HEX String - an integer block number
  • String "earliest" for the earliest/genesis block
  • String "latest" - for the latest mined block
  • String "pending" - for the pending state/transactions

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 . If your node does complain, manually set the header by placing -H "Content-Type: application/json" at the start of the call.

The examples also do not include the URL/IP & port combination which must be the last argument given to curl e.x. 127.0.0.1:8585

JSON-RPC methods

JSON RPC API Reference


web3_clientVersion

Returns the current client version.

Parameters

none

Returns

String - The current client version.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}'

// Result
{
  "id":67,
  "jsonrpc":"2.0",
  "result": "Gvns/v2.0.1-unstable-425c18d3/linux-amd64/go1.9.3"
}

web3_sha3

Returns Keccak-256 (not the standardized SHA3-256) of the given data.

Parameters
  1. DATA - the data to convert into a SHA3 hash.
Example Parameters
params: [
  "0x68656c6c6f20776f726c64"
]
Returns

DATA - The SHA3 result of the given string.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"web3_sha3","params":["0x68656c6c6f20776f726c64"],"id":64}'

// Result
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"
}

net_version

Returns the current network id.

Parameters

none

Returns

String - The current network id.

  • "1314595": VNS Mainnet
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":67}'

// Result
{
  "id":67,
  "jsonrpc": "2.0",
  "result": "1314595"
}

net_listening

Returns true if client is actively listening for network connections.

Parameters

none

Returns

Boolean - true when listening, otherwise false.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_listening","params":[],"id":67}'

// Result
{
  "id":67,
  "jsonrpc":"2.0",
  "result":true
}

net_peerCount

Returns number of peers currently connected to the client.

Parameters

none

Returns

QUANTITY - integer of the number of connected peers.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":74}'

// Result
{
  "id":74,
  "jsonrpc": "2.0",
  "result": "0x2" // 2
}

vns_protocolVersion

Returns the current Vnschain protocol version.

Parameters

none

Returns

String - The current Vnschain protocol version.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_protocolVersion","params":[],"id":67}'

// Result
{
  "id":67,
  "jsonrpc": "2.0",
  "result": "0x3f"
}

vns_syncing

Returns an object with data about the sync status or false.

Parameters

none

Returns

Object|Boolean, An object with sync status data or FALSE, when not syncing:

  • startingBlock: QUANTITY - The block at which the import started (will only be reset, after the sync reached his head)
  • currentBlock: QUANTITY - The current block, same as vns_blockNumber
  • highestBlock: QUANTITY - The estimated highest block
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_syncing","params":[],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": {
    startingBlock: '0x384',
    currentBlock: '0x386',
    highestBlock: '0x454'
  }
}
// Or when not syncing
{
  "id":1,
  "jsonrpc": "2.0",
  "result": false
}

vns_coinbase

Returns the client coinbase address.

Parameters

none

Returns

DATA, 20 bytes - the current coinbase address.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_coinbase","params":[],"id":64}'

// Result
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "0x672cb82250c5b966dc9b1d29b7cd0ce0d32dae5f"
}

vns_mining

Returns true if client is actively mining new blocks.

Parameters

none

Returns

Boolean - returns true of the client is mining, otherwise false.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_mining","params":[],"id":71}'

// Result
{
  "id":71,
  "jsonrpc": "2.0",
  "result": false
}

vns_hashrate

Returns the number of hashes per second that the node is mining with.

Parameters

none

Returns

QUANTITY - number of hashes per second.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_hashrate","params":[],"id":71}'

// Result
{
  "id":71,
  "jsonrpc": "2.0",
  "result": "0x17
}

vns_gasPrice

Returns the current price per gas in wei.

Parameters

none

Returns

QUANTITY - integer of the current gas price in wei.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_gasPrice","params":[],"id":73}'

// Result
{
  "id":73,
  "jsonrpc": "2.0",
  "result": "0xba43b7400" // 50000000000
}

vns_accounts

Returns a list of addresses owned by client.

Parameters

none

Returns

Array of DATA, 20 Bytes - addresses owned by the client.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_accounts","params":[],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": ["0x672cb82250c5b966dc9b1d29b7cd0ce0d32dae5f","0x3ce193e490b7b1e45c50517a0afb1f64467b8ad2"]
}

vns_blockNumber

Returns the number of most recent block.

Parameters

none

Returns

QUANTITY - integer of the current block number the client is on.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_blockNumber","params":[],"id":1}'

// Result
{
  "id":83,
  "jsonrpc": "2.0",
  "result": "0x2189" // 8585
}

vns_getBalance

Returns the balance of the account of given address.

Parameters
  1. DATA, 20 Bytes - address to check for balance.
  2. QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the default block parameter
Example Parameters
params: [
   '0x96C05c702EF837815f6cE9196Fe4C2D386eDb462',
   'latest'
]
Returns

QUANTITY - integer of the current balance in wei.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getBalance","params":["0x96C05c702EF837815f6cE9196Fe4C2D386eDb462", "latest"],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x6b9f2620bb17edc00" // 124079344086000000000 wei
}

vns_getStorageAt

Returns the value from a storage position at a given address.

Parameters
  1. DATA, 20 Bytes - address of the storage.
  2. QUANTITY - integer of the position in the storage.
  3. QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the default block parameter
Returns

DATA - the value at this storage position.

Example

Calculating the correct position depends on the storage to retrieve. Consider the following contract deployed at 0x5ec3ba763a80614ceb8af15cfc90e9e6c8b6234a by address 0x672cb82250c5b966dc9b1d29b7cd0ce0d32dae5f.

contract Storage {
    uint pos0;
    mapping(address => uint) pos1;
    
    function Storage() {
        pos0 = 1234;
        pos1[msg.sender] = 5678;
    }
}

Retrieving the value of pos0 is straight forward:

curl -X POST --data '{"jsonrpc":"2.0", "method": "vns_getStorageAt", "params": ["0x5ec3ba763a80614ceb8af15cfc90e9e6c8b6234a", "0x0", "latest"], "id": 1}'

{"jsonrpc":"2.0","id":1,"result":"0x00000000000000000000000000000000000000000000000000000000000004d2"}

Retrieving an element of the map is harder. The position of an element in the map is calculated with:

keccack(LeftPad32(key, 0), LeftPad32(map position, 0))

This means to retrieve the storage on pos1["0x672cb82250c5b966dc9b1d29b7cd0ce0d32dae5f"] we need to calculate the position with:

keccak(decodeHex("000000000000000000000000672cb82250c5b966dc9b1d29b7cd0ce0d32dae5f" + "0000000000000000000000000000000000000000000000000000000000000001"))

The gvns console which comes with the web3 library can be used to make the calculation:

> var key = "000000000000000000000000672cb82250c5b966dc9b1d29b7cd0ce0d32dae5f" + "0000000000000000000000000000000000000000000000000000000000000001"
undefined
> web3.sha3(key, {"encoding": "hex"})
"0x58f4a937289e1782309dc2622220029dcdbb6d3de8d64be14ba49bc2b97ba0af"

Now to fetch the storage:

curl -X POST --data '{"jsonrpc":"2.0", "method": "vns_getStorageAt", "params": ["0x5ec3ba763a80614ceb8af15cfc90e9e6c8b6234a", "0x58f4a937289e1782309dc2622220029dcdbb6d3de8d64be14ba49bc2b97ba0af", "latest"], "id": 1}'

{"jsonrpc":"2.0","id":1,"result":"0x000000000000000000000000000000000000000000000000000000000000162e"}

vns_getTransactionCount

Returns the number of transactions sent from an address.

Parameters
  1. DATA, 20 Bytes - address.
  2. QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the default block parameter
Example Parameters
params: [
   '0x672cb82250c5b966dc9b1d29b7cd0ce0d32dae5f',
   'latest' // state at the latest block
]
Returns

QUANTITY - integer of the number of transactions send from this address.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getTransactionCount","params":["0x672cb82250c5b966dc9b1d29b7cd0ce0d32dae5f","latest"],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x91" // 145
}

vns_getBlockTransactionCountByHash

Returns the number of transactions in a block from a block matching the given block hash.

Parameters
  1. DATA, 32 Bytes - hash of a block.
Example Parameters
params: [
   '0x2c661ca204dfa784334162bac133437e73fada9564d90728132ee8513102536b'
]
Returns

QUANTITY - integer of the number of transactions in this block.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getBlockTransactionCountByHash","params":["0x2c661ca204dfa784334162bac133437e73fada9564d90728132ee8513102536b"],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": ""0x1" // 1
}

vns_getBlockTransactionCountByNumber

Returns the number of transactions in a block matching the given block number.

Parameters
  1. QUANTITY|TAG - integer of a block number, or the string "earliest", "latest" or "pending", as in the default block parameter.
Example Parameters
params: [
   '0x315e39', // 3235385
]
Returns

QUANTITY - integer of the number of transactions in this block.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getBlockTransactionCountByNumber","params":["0x315e39"],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x1" // 1
}

vns_getUncleCountByBlockHash

Returns the number of uncles in a block from a block matching the given block hash.

Parameters
  1. DATA, 32 Bytes - hash of a block.
Example Parameters
params: [
   '0x2c661ca204dfa784334162bac133437e73fada9564d90728132ee8513102536b'
]
Returns

QUANTITY - integer of the number of uncles in this block.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getUncleCountByBlockHash","params":["0x2c661ca204dfa784334162bac133437e73fada9564d90728132ee8513102536b"],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x0" // 0
}

vns_getUncleCountByBlockNumber

Returns the number of uncles in a block from a block matching the given block number.

Parameters
  1. QUANTITY|TAG - integer of a block number, or the string "latest", "earliest" or "pending", see the default block parameter.
params: [
   '0x315e19', // 3235353
]
Returns

QUANTITY - integer of the number of uncles in this block.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getUncleCountByBlockNumber","params":["0x315e19"],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x1" // 1
}

vns_getCode

Returns code at a given address.

Parameters
  1. DATA, 20 Bytes - the contract address.
  2. QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the default block parameter.
Example Parameters
params: [
   '0x5ec3ba763a80614ceb8af15cfc90e9e6c8b6234a',
   'latest' 
]
Returns

DATA - the code from the given address.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getCode","params":["0x5ec3ba763a80614ceb8af15cfc90e9e6c8b6234a","latest"],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x6080604052600080fd00a165627a7a723058203ea8594741f6c494ce9291d45e379534b9aaf2ef63878a9e3fae90d784452a850029"
}

vns_sign

The sign method calculates an Vnscoin specific signature with: sign(keccak256("\x19Vnscoin Signed Message:\n" + len(message) + message))).

By adding a prefix to the message makes the calculated signature recognisable as an Vnscoin specific signature. This prevents misuse where a malicious DApp can sign arbitrary data (e.g. transaction) and use the signature to impersonate the victim.

Note the address to sign with must be unlocked.

Parameters

account, message

  1. DATA, 20 Bytes - address.
  2. DATA, N Bytes - message to sign.
Returns

DATA: Signature

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_sign","params":["0x3ce193e490b7b1e45c50517a0afb1f64467b8ad2", "0xdeadbeaf"],"id":1}'

// Result
{
  "jsonrpc": "2.0",
  "id":1,
  "result":"0x6c6d3d6b0d16ff3ad99b03284809a2e7984f47115a3d3c292e2454ea4d902ed814a2463cb1a6051766546f586f585d1d9610bf4a456d3a9610c13d1093f452691b"
}

vns_sendTransaction

Creates new message call transaction or a contract creation, if the data field contains code.

Parameters
  1. Object - The transaction object
  • from: DATA, 20 Bytes - The address the transaction is send from.
  • to: DATA, 20 Bytes - (optional when creating new contract) The address the transaction is directed to.
  • gas: QUANTITY - (optional, default: 90000) Integer of the gas provided for the transaction execution. It will return unused gas.
  • gasPrice: QUANTITY - (optional, default: To-Be-Determined) Integer of the gasPrice used for each paid gas
  • value: QUANTITY - (optional) Integer of the value sent with this transaction
  • data: DATA - The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see Vnscoin Contract ABI
  • nonce: QUANTITY - (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
Example Parameters
params: [{
  "from": "0x672cb82250c5b966dc9b1d29b7cd0ce0d32dae5f",
  "to": "0x3ce193e490b7b1e45c50517a0afb1f64467b8ad2",
  "gas": "0x76c0", // 30400
  "gasPrice": "0x9184e72a000", // 10000000000000
  "value": "0x9184e72a", // 2441406250
  "data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}]
Returns

DATA, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.

Use vns_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_sendTransaction","params":[{see above}],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x544cf930dc7035fe0a1eb62a0541609ef01734661bcc0270b15cebf48dd7d34c"
}

vns_sendRawTransaction

Creates new message call transaction or a contract creation for signed transactions.

Parameters
  1. DATA, The signed transaction data.
Example Parameters
params: ["0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"]
Returns

DATA, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.

Use vns_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_sendRawTransaction","params":[{see above}],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}

vns_call

Executes a new message call immediately without creating a transaction on the block chain.

Parameters
  1. Object - The transaction call object
  • from: DATA, 20 Bytes - (optional) The address the transaction is sent from.
  • to: DATA, 20 Bytes - The address the transaction is directed to.
  • gas: QUANTITY - (optional) Integer of the gas provided for the transaction execution. vns_call consumes zero gas, but this parameter may be needed by some executions.
  • gasPrice: QUANTITY - (optional) Integer of the gasPrice used for each paid gas
  • value: QUANTITY - (optional) Integer of the value sent with this transaction
  • data: DATA - (optional) Hash of the method signature and encoded parameters. For details see Vnscoin Contract ABI
  1. QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the default block parameter
Returns

DATA - the return value of executed contract.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_call","params":[{see above}],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x"
}

vns_estimateGas

Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the amount of gas actually used by the transaction, for a variety of reasons including EVM mechanics and node performance.

Parameters

See vns_call parameters, expect that all properties are optional. If no gas limit is specified gvnsuses the block gas limit from the pending block as an upper bound. As a result the returned estimate might not be enough to executed the call/transaction when the amount of gas is higher than the pending block gas limit.

Returns

QUANTITY - the amount of gas used.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_estimateGas","params":[{see above}],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x5208" // 21000
}

vns_getBlockByHash

Returns information about a block by hash.

Parameters
  1. DATA, 32 Bytes - Hash of a block.
  2. Boolean - If true it returns the full transaction objects, if false only the hashes of the transactions.
Example Parameters
params: [
   '0x2c661ca204dfa784334162bac133437e73fada9564d90728132ee8513102536b',
   true
]
Returns

Object - A block object, or null when no block was found:

  • number: QUANTITY - the block number. null when its pending block.
  • hash: DATA, 32 Bytes - hash of the block. null when its pending block.
  • parentHash: DATA, 32 Bytes - hash of the parent block.
  • nonce: DATA, 8 Bytes - hash of the generated proof-of-work. null when its pending block.
  • sha3Uncles: DATA, 32 Bytes - SHA3 of the uncles data in the block.
  • logsBloom: DATA, 256 Bytes - the bloom filter for the logs of the block. null when its pending block.
  • transactionsRoot: DATA, 32 Bytes - the root of the transaction trie of the block.
  • stateRoot: DATA, 32 Bytes - the root of the final state trie of the block.
  • receiptsRoot: DATA, 32 Bytes - the root of the receipts trie of the block.
  • miner: DATA, 20 Bytes - the address of the beneficiary to whom the mining rewards were given.
  • difficulty: QUANTITY - integer of the difficulty for this block.
  • totalDifficulty: QUANTITY - integer of the total difficulty of the chain until this block.
  • extraData: DATA - the "extra data" field of this block.
  • size: QUANTITY - integer the size of this block in bytes.
  • gasLimit: QUANTITY - the maximum gas allowed in this block.
  • gasUsed: QUANTITY - the total used gas by all transactions in this block.
  • timestamp: QUANTITY - the unix timestamp for when the block was collated.
  • transactions: Array - Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
  • uncles: Array - Array of uncle hashes.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getBlockByHash","params":["0x2c661ca204dfa784334162bac133437e73fada9564d90728132ee8513102536b", true],"id":1}'

// Result
{
"id":1,
"jsonrpc":"2.0",
"result":{
    "difficulty":"0x407adec",
    "extraData":"0xda830200018467766e7388676f312e31322e358777696e646f7773",
    "gasLimit":"0x7a1200",
    "gasUsed":"0x5208",
    "hash":"0x2c661ca204dfa784334162bac133437e73fada9564d90728132ee8513102536b",
    "logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "miner":"0x501f5aa2944998d83417e29345b501b4d8edac13",
    "mixHash":"0x0000001008fda27a9e6a4b10bbb0d389c9338427bb97752f022ad806fae47ebc",
    "nonce":"0x6a7401380000151e",
    "number":"0x315e39",
    "parentHash":"0x7c381caec0f06add5856e056598de0e85263a4eca1fa2f907779dbae225d7761",
    "receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2",
    "sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "size":"0x290",
    "stateRoot":"0x77d63788b0b0bd2aacf4c88abd3b5f37418256fcc49dfacdb3f892d2d39fe9ad",
    "timestamp":"0x5e034a20",
    "totalDifficulty":"0x15034125c3a7c",
    "transactions":[{"blockHash":"0x2c661ca204dfa784334162bac133437e73fada9564d90728132ee8513102536b","blockNumber":"0x315e39","from":"0xbd66bf17d87c79e5562bfce2a0b0ad05b7585311","gas":"0x15f90","gasPrice":"0xa","hash":"0xa31876af5594959cd7af51377379a58ce7ded3f5139cb174c07f39beefb2b445","input":"0x","nonce":"0x95","to":"0x9ce7b6a7ddfec22878b93a5f180100bd059683a9","transactionIndex":"0x0","value":"0x10849e1eb899565d7b0","v":"0xfe7","r":"0x1fa2c7ac373121efb8c2af0802c77a1389518a29aecbf80c99c046c47579bf32","s":"0x1af0b478c9b3d009a2ac7cc08f7267d6384c5dcf6df7b7cc662dbf84fa60cc0a"}],
    "transactionsRoot":"0x897d49fbf3e4e726a4048c027c2bc3090acd0e60a257ae1345fb8b3a715de95a",
    "uncles":[]
    }
}

vns_getBlockByNumber

Returns information about a block by block number.

Parameters
  1. QUANTITY|TAG - integer of a block number, or the string "earliest", "latest" or "pending", as in the default block parameter.
  2. Boolean - If true it returns the full transaction objects, if false only the hashes of the transactions.
Example Parameters
params: [
   '0x315e39', // 3235385
   true
]
Returns

See vns_getBlockByHash

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getBlockByNumber","params":["0x315e39", true],"id":1}'

Result see vns_getBlockByHash


vns_getTransactionByHash

Returns the information about a transaction requested by transaction hash.

Parameters
  1. DATA, 32 Bytes - hash of a transaction
Example Parameters
params: [
   "0xa31876af5594959cd7af51377379a58ce7ded3f5139cb174c07f39beefb2b445"
]
Returns

Object - A transaction object, or null when no transaction was found:

  • blockHash: DATA, 32 Bytes - hash of the block where this transaction was in. null when its pending.
  • blockNumber: QUANTITY - block number where this transaction was in. null when its pending.
  • from: DATA, 20 Bytes - address of the sender.
  • gas: QUANTITY - gas provided by the sender.
  • gasPrice: QUANTITY - gas price provided by the sender in Wei.
  • hash: DATA, 32 Bytes - hash of the transaction.
  • input: DATA - the data send along with the transaction.
  • nonce: QUANTITY - the number of transactions made by the sender prior to this one.
  • to: DATA, 20 Bytes - address of the receiver. null when its a contract creation transaction.
  • transactionIndex: QUANTITY - integer of the transaction's index position in the block. null when its pending.
  • value: QUANTITY - value transferred in Wei.
  • v: QUANTITY - ECDSA recovery id
  • r: QUANTITY - ECDSA signature r
  • s: QUANTITY - ECDSA signature s
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getTransactionByHash","params":["0xa31876af5594959cd7af51377379a58ce7ded3f5139cb174c07f39beefb2b445"],"id":1}'

// Result
{
  "jsonrpc":"2.0",
  "id":1,
  "result":{
    "blockHash":"0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2",
    "blockNumber":"0x5daf3b", // 6139707
    "from":"0xa7d9ddbe1f17865597fbd27ec712455208b6b76d",
    "gas":"0xc350", // 50000
    "gasPrice":"0x4a817c800", // 20000000000
    "hash":"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b",
    "input":"0x68656c6c6f21",
    "nonce":"0x15", // 21
    "to":"0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb",
    "transactionIndex":"0x41", // 65
    "value":"0xf3dbb76162000", // 4290000000000000
    "v":"0x25", // 37
    "r":"0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
    "s":"0x4ba69724e8f69de52f0125ad8b3c5c2cef33019bac3249e2c0a2192766d1721c"
  }
}

vns_getTransactionByBlockHashAndIndex

Returns information about a transaction by block hash and transaction index position.

Parameters
  1. DATA, 32 Bytes - hash of a block.
  2. QUANTITY - integer of the transaction index position.
Example Parameters
params: [
   '0x2c661ca204dfa784334162bac133437e73fada9564d90728132ee8513102536b',
   '0x0' // 0
]
Returns

See vns_getTransactionByHash

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getTransactionByBlockHashAndIndex","params":["0x2c661ca204dfa784334162bac133437e73fada9564d90728132ee8513102536b", "0x0"],"id":1}'

Result see vns_getTransactionByHash


vns_getTransactionByBlockNumberAndIndex

Returns information about a transaction by block number and transaction index position.

Parameters
  1. QUANTITY|TAG - a block number, or the string "earliest", "latest" or "pending", as in the default block parameter.
  2. QUANTITY - the transaction index position.
Example Parameters
params: [
   '0x315e39', // 3235385
   '0x0' // 0
]
Returns

See vns_getTransactionByHash

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getTransactionByBlockNumberAndIndex","params":["0x315e39", "0x0"],"id":1}'

Result see vns_getTransactionByHash


vns_getTransactionReceipt

Returns the receipt of a transaction by transaction hash.

Note That the receipt is not available for pending transactions.

Parameters
  1. DATA, 32 Bytes - hash of a transaction
Example Parameters
params: [
   '0xa31876af5594959cd7af51377379a58ce7ded3f5139cb174c07f39beefb2b445'
]
Returns

Object - A transaction receipt object, or null when no receipt was found:

  • transactionHash : DATA, 32 Bytes - hash of the transaction.
  • transactionIndex: QUANTITY - integer of the transaction's index position in the block.
  • blockHash: DATA, 32 Bytes - hash of the block where this transaction was in.
  • blockNumber: QUANTITY - block number where this transaction was in.
  • from: DATA, 20 Bytes - address of the sender.
  • to: DATA, 20 Bytes - address of the receiver. null when it's a contract creation transaction.
  • cumulativeGasUsed : QUANTITY - The total amount of gas used when this transaction was executed in the block.
  • gasUsed : QUANTITY - The amount of gas used by this specific transaction alone.
  • contractAddress : DATA, 20 Bytes - The contract address created, if the transaction was a contract creation, otherwise null.
  • logs: Array - Array of log objects, which this transaction generated.
  • logsBloom: DATA, 256 Bytes - Bloom filter for light clients to quickly retrieve related logs.

It also returns either :

  • root : DATA 32 bytes of post-transaction stateroot (pre Byzantium)
  • status: QUANTITY either 1 (success) or 0 (failure)
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getTransactionReceipt","params":["0xa31876af5594959cd7af51377379a58ce7ded3f5139cb174c07f39beefb2b445"],"id":1}'

// Result
{
    "jsonrpc": "2.0", 
     "id": 1, 
     "result": {
                 "blockHash": "0x2c661ca204dfa784334162bac133437e73fada9564d90728132ee8513102536b", 
                 "blockNumber": "0x315e39", 
                 "contractAddress": null, 
                 "cumulativeGasUsed": "0x5208", //21000
                 "from": "0xbd66bf17d87c79e5562bfce2a0b0ad05b7585311", 
                 "gasUsed": "0x5208", //21000
                 "logs": [ {
                     // logs as returned by getFilterLogs, etc.
                 }, ...], 
                 "logsBloom": "0x00...0", // 256 byte bloom filter
                 "status": "0x1", 
                 "to": "0x9ce7b6a7ddfec22878b93a5f180100bd059683a9", 
                 "transactionHash": "0xa31876af5594959cd7af51377379a58ce7ded3f5139cb174c07f39beefb2b445", 
                 "transactionIndex": "0x0"
             }  
}

vns_pendingTransactions

Returns the pending transactions list.

Parameters

none

Returns

Array - A list of pending transactions.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_pendingTransactions","params":[],"id":1}'

// Result
{
"id":1,
"jsonrpc":"2.0",
"result": [{ 
    blockHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
    blockNumber: null,
    from: '0x28bdb9c230f4d5e45435e4d006326ee32e46cb31',
    gas: '0x204734',
    gasPrice: '0x4a817c800',
    hash: '0x8dfa6a59307a490d672494a171feee09db511f05e9c097e098edc2881f9ca4f6',
    input: '0x6080604052600',
    nonce: '0x12',
    to: null,
    transactionIndex: '0x0',
    value: '0x0',
    v: '0x3d',
    r: '0xaabc9ddafffb2ae0bac4107697547d22d9383667d9e97f5409dd6881ce08f13f',
    s: '0x69e43116be8f842dcd4a0b2f760043737a59534430b762317db21d9ac8c5034' 
   },....,{ 
    blockHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
    blockNumber: null,
    from: '0x28bdb9c230f4d5e45435e4d006326ee32e487b31',
    gas: '0x205940',
    gasPrice: '0x4a817c800',
    hash: '0x8e4340ea3983d86e4b6c44249362f716ec9e09849ef9b6e3321140581d2e4dac',
    input: '0xe4b6c4424936',
    nonce: '0x14',
    to: null,
    transactionIndex: '0x0',
    value: '0x0',
    v: '0x3d',
    r: '0x1ec191ef20b0e9628c4397665977cbe7a53a263c04f6f185132b77fa0fd5ca44',
    s: '0x8a58e00c63e05cfeae4f1cf19f05ce82079dc4d5857e2cc281b7797d58b5faf' 
   }]
}

vns_getUncleByBlockHashAndIndex

Returns information about a uncle of a block by hash and uncle index position.

Parameters
  1. DATA, 32 Bytes - hash a block.
  2. QUANTITY - the uncle's index position.
params: [
   '0x2c661ca204dfa784334162bac133437e73fada9564d90728132ee8513102536b',
   '0x0' // 0
]
Returns

See vns_getBlockByHash

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getUncleByBlockHashAndIndex","params":["0x2c661ca204dfa784334162bac133437e73fada9564d90728132ee8513102536b", "0x0"],"id":1}'

Result see vns_getBlockByHash

Note: An uncle doesn't contain individual transactions.


vns_getUncleByBlockNumberAndIndex

Returns information about a uncle of a block by number and uncle index position.

Parameters
  1. QUANTITY|TAG - a block number, or the string "earliest", "latest" or "pending", as in the default block parameter.
  2. QUANTITY - the uncle's index position.
Example Parameters
params: [
   '0x315e39', // 3235385
   '0x0' // 0
]
Returns

See vns_getBlockByHash

Note: An uncle doesn't contain individual transactions.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getUncleByBlockNumberAndIndex","params":["0x15e39", "0x0"],"id":1}'

Result see vns_getBlockByHash


vns_newFilter

Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call vns_getFilterChanges.

A note on specifying topic filters:

Topics are order-dependent. A transaction with a log with topics [A, B] will be matched by the following topic filters:

  • [] "anything"
  • [A] "A in first position (and anything after)"
  • [null, B] "anything in first position AND B in second position (and anything after)"
  • [A, B] "A in first position AND B in second position (and anything after)"
  • [[A, B], [A, B]] "(A OR B) in first position AND (A OR B) in second position (and anything after)"
Parameters
  1. Object - The filter options:
  • fromBlock: QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
  • toBlock: QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
  • address: DATA|Array, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.
  • topics: Array of DATA, - (optional) Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
Example Parameters
params: [{
  "fromBlock": "0x1",
  "toBlock": "0x2",
  "address": "0x3f5c17c4ee9f3df536d1ea1e64e370d441245df4",
  "topics": ["0xf4cd1f8571e8d9c97ffcb81558807ab73f9803d54de5da6a0420593c82a4a9f0"]
}]
Returns

QUANTITY - A filter id.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_newFilter","params":[{"fromBlock": "0x1","toBlock": "0x31b5dc","address": "0x3f5c17c4ee9f3df536d1ea1e64e370d441245df4","topics":["0xf4cd1f8571e8d9c97ffcb81558807ab73f9803d54de5da6a0420593c82a4a9f0"]}],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x64ab4363b166a8115715320cb6dc4f02"
}

vns_newBlockFilter

Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call vns_getFilterChanges.

Parameters

None

Returns

QUANTITY - A filter id.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_newBlockFilter","params":[],"id":56}'

// Result
{
  "id":56,
  "jsonrpc":  "2.0",
  "result": "0xc4f87dbb2de35b09cc6aa260dea2faca"
}

vns_newPendingTransactionFilter

Creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call vns_getFilterChanges.

Parameters

None

Returns

QUANTITY - A filter id.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_newPendingTransactionFilter","params":[],"id":73}'

// Result
{
  "id":1,
  "jsonrpc":  "2.0",
  "result": "0x49afa117bf0f4436e95a491f9da3baba"
}

vns_uninstallFilter

Uninstalls a filter with given id. Should always be called when watch is no longer needed. Additonally Filters timeout when they aren't requested with vns_getFilterChanges for a period of time.

Parameters
  1. QUANTITY - The filter id.
Example Parameters
params: [
  "0x423fefe983b0ee1c959a04d28c4324f3"
]
Returns

Boolean - true if the filter was successfully uninstalled, otherwise false.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_uninstallFilter","params":["0x423fefe983b0ee1c959a04d28c4324f3"],"id":73}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": true
}

vns_getFilterChanges

Polling method for a filter, which returns an array of logs which occurred since last poll.

Parameters
  1. QUANTITY - the filter id.
Example Parameters
params: [
  "0x423fefe983b0ee1c959a04d28c4324f3"
]
Returns

Array - Array of log objects, or an empty array if nothing has changed since last poll.

  • For filters created with vns_newBlockFilter the return are block hashes (DATA, 32 Bytes), e.g. ["0x3454645634534..."].

  • For filters created with vns_newPendingTransactionFilter the return are transaction hashes (DATA, 32 Bytes), e.g. ["0x6345343454645..."].

  • For filters created with vns_newFilter logs are objects with following params:

    • removed: TAG - true when the log was removed, due to a chain reorganization. false if its a valid log.
    • logIndex: QUANTITY - integer of the log index position in the block. null when its pending log.
    • transactionIndex: QUANTITY - integer of the transactions index position log was created from. null when its pending log.
    • transactionHash: DATA, 32 Bytes - hash of the transactions this log was created from. null when its pending log.
    • blockHash: DATA, 32 Bytes - hash of the block where this log was in. null when its pending. null when its pending log.
    • blockNumber: QUANTITY - the block number where this log was in. null when its pending. null when its pending log.
    • address: DATA, 20 Bytes - address from which this log originated.
    • data: DATA - contains the non-indexed arguments of the log.
    • topics: Array of DATA - Array of 0 to 4 32 Bytes DATA of indexed log arguments. (In solidity: The first topic is the hash of the signature of the event (e.g. Deposit(address,bytes32,uint256)), except you declared the event with the anonymous specifier.)
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getFilterChanges","params":["0x423fefe983b0ee1c959a04d28c4324f3"],"id":73}'

// Result
{
  "id":1,
  "jsonrpc":"2.0",
  "result": [{
    "logIndex": "0x1", // 1
    "blockNumber":"0x1b4", // 436
    "blockHash": "0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d",
    "transactionHash":  "0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf",
    "transactionIndex": "0x0", // 0
    "address": "0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d",
    "data":"0x0000000000000000000000000000000000000000000000000000000000000000",
    "topics": ["0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5"]
    },{
      ...
    }]
}

vns_getFilterLogs

Returns an array of all logs matching filter with given id.

Parameters
  1. QUANTITY - The filter id.
Example Parameters
params: [
  "0x16" // 22
]
Returns

See vns_getFilterChanges

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getFilterLogs","params":["0x16"],"id":74}'

Result see vns_getFilterChanges


vns_getLogs

Returns an array of all logs matching a given filter object.

Parameters
  1. Object - The filter options:
  • fromBlock: QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
  • toBlock: QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
  • address: DATA|Array, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.
  • topics: Array of DATA, - (optional) Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
  • blockhash: DATA, 32 Bytes - (optional) With the addition of EIP-234, blockHash is a new filter option which restricts the logs returned to the single block with the 32-byte hash blockHash. Using blockHash is equivalent to fromBlock = toBlock = the block number with hash blockHash. If blockHash is present in the filter criteria, then neither fromBlock nor toBlock are allowed.
Example Parameters
params: [{
  "topics": ["0xf4cd1f8571e8d9c97ffcb81558807ab73f9803d54de5da6a0420593c82a4a9f0"]
}]
Returns

See vns_getFilterChanges

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getLogs","params":[{"topics": ["0xf4cd1f8571e8d9c97ffcb81558807ab73f9803d54de5da6a0420593c82a4a9f0"]]}],"id":74}'

Result see vns_getFilterChanges


vns_getWork

Returns the hash of the current block, the seedHash, and the boundary condition to be met ("target").

Parameters

none

Returns

Array - Array with the following properties:

  1. DATA, 32 Bytes - current block header pow-hash
  2. DATA, 32 Bytes - the seed hash used for the DAG.
  3. DATA, 32 Bytes - the boundary condition ("target"), 2^256 / difficulty.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"vns_getWork","params":[],"id":73}'

// Result
{
  "id":73,
  "jsonrpc":"2.0",
  "result": [
      "0x05dde4fe93a9f52d5558ec3b23d72bc96d2035c37d22e73229168d7c6268d386",
      "0xa20ad88dc5bc23e45a05b2b048f7747baf43ec80b78873ca38acf192442a10e8",
      "0x00000027cd981e32912d41f8670455a524f87b824251d0e9115b15007a38591c"
    ]
}

vns_submitWork

Used for submitting a proof-of-work solution.

Parameters
  1. DATA, 8 Bytes - The nonce found (64 bits)
  2. DATA, 32 Bytes - The header's pow-hash (256 bits)
  3. DATA, 32 Bytes - The mix digest (256 bits)
Example Parameters
params: [
  "0x0000000000000001",
  "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
  "0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000"
]
Returns

Boolean - returns true if the provided solution is valid, otherwise false.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0", "method":"vns_submitWork", "params":["0x0000000000000001", "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", "0xD1GE5700000000000000000000000000D1GE5700000000000000000000000000"],"id":73}'

// Result
{
  "id":73,
  "jsonrpc":"2.0",
  "result": true
}

vns_submitHashrate

Used for submitting mining hashrate.

Parameters
  1. Hashrate, a hexadecimal string representation (32 bytes) of the hash rate
  2. ID, String - A random hexadecimal(32 bytes) ID identifying the client
Example Parameters
params: [
  "0x0000000000000000000000000000000000000000000000000000000000500000",
  "0x59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c"
]
Returns

Boolean - returns true if submitting went through succesfully and false otherwise.

Example
// Request
curl -X POST --data '{"jsonrpc":"2.0", "method":"vns_submitHashrate", "params":["0x0000000000000000000000000000000000000000000000000000000000500000", "0x59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c"],"id":73}'

// Result
{
  "id":73,
  "jsonrpc":"2.0",
  "result": true
}

Clone this wiki locally