JSON RPC
Contents
JSON RPC API
JavaScript API
JSON-RPC Endpoint
Go
JSON-RPC support
HEX value encoding
The default block parameter
Curl Examples Explained
JSON-RPC methods
JSON RPC API Reference
web3_clientVersion
Parameters
Returns
Example
web3_sha3
Parameters
Example Parameters
Returns
Example
net_version
Parameters
Returns
Example
net_listening
Parameters
Returns
Example
net_peerCount
Parameters
Returns
Example
eth_protocolVersion
Parameters
Returns
Example
eth_syncing
Parameters
Returns
Example
eth_coinbase
Parameters
Returns
Example
eth_mining
Parameters
Returns
Example
eth_hashrate
Parameters
Returns
Example
eth_gasPrice
Parameters
Returns
Example
eth_accounts
Parameters
Returns
Example
eth_blockNumber
Parameters
Returns
Example
eth_getBalance
Parameters
Example Parameters
Returns
Example
eth_getStorageAt
Parameters
Returns
Example
eth_getTransactionCount
Parameters
Example Parameters
Returns
Example
eth_getBlockTransactionCountByHash
Parameters
Example Parameters
Returns
Example
eth_getBlockTransactionCountByNumber
Parameters
Example Parameters
Returns
Example
eth_getUncleCountByBlockHash
Parameters
Example Parameters
Returns
Example
eth_getUncleCountByBlockNumber
Parameters
Returns
Example
eth_getCode
Parameters
Example Parameters
Returns
Example
eth_sign
Parameters
Returns
Example
eth_sendTransaction
Parameters
Example Parameters
Returns
Example
eth_sendRawTransaction
Parameters
Example Parameters
Returns
Example
eth_call
Parameters
Returns
Example
eth_estimateGas
Parameters
Returns
Example
eth_getBlockByHash
Parameters
Example Parameters
Returns
Example
eth_getBlockByNumber
Parameters
Example Parameters
Returns
Example
eth_getTransactionByHash
Parameters
Example Parameters
Returns
Example
eth_getTransactionByBlockHashAndIndex
Parameters
Example Parameters
Returns
Example
eth_getTransactionByBlockNumberAndIndex
Parameters
Example Parameters
Returns
Example
eth_getTransactionReceipt
Parameters
Example Parameters
Returns
Example
eth_pendingTransactions
Parameters
Example Parameters
Returns
Example
eth_getUncleByBlockHashAndIndex
Parameters
Returns
Example
eth_getUncleByBlockNumberAndIndex
Parameters
Example Parameters
Returns
Example
eth_getCompilers (DEPRECATED)
Parameters
Returns
Example
eth_compileSolidity (DEPRECATED)
Parameters
Example Parameters
Returns
Example
eth_compileLLL (DEPRECATED)
Parameters
Example Parameters
Returns
Example
eth_compileSerpent (DEPRECATED)
Parameters
Example Parameters
Returns
Example
eth_newFilter
A note on specifying topic filters:
Parameters
Example Parameters
Returns
Example
eth_newBlockFilter
Parameters
Returns
Example
eth_newPendingTransactionFilter
Parameters
Returns
Example
eth_uninstallFilter
Parameters
Example Parameters
Returns
Example
eth_getFilterChanges
Parameters
Example Parameters
Returns
Example
eth_getFilterLogs
Parameters
Example Parameters
Returns
Example
eth_getLogs
Parameters
Example Parameters
Returns
Example
eth_getWork
Parameters
Returns
Example
eth_submitWork
Parameters
Example Parameters
Returns
Example
eth_submitHashrate
Parameters
Example Parameters
Returns
Example
eth_getProof
getProof-Parameters
Example Parameters
getProof-Returns
getProof-Example
db_putString
Parameters
Example Parameters
Returns
Example
db_getString
Parameters
Example Parameters
Returns
Example
db_putHex
Parameters
Example Parameters
Returns
Example
db_getHex
Parameters
Example Parameters
Returns
Example
shh_version
Parameters
Returns
Example
shh_post
Parameters
Example Parameters
Returns
Example
shh_newIdentity
Parameters
Returns
Example
shh_hasIdentity
Parameters
Example Parameters
Returns
Example
shh_newGroup
Parameters
Returns
Example
shh_addToGroup
Parameters
Example Parameters
Returns
Example
shh_newFilter
Parameters
Example Parameters
Returns
Example
shh_uninstallFilter
Parameters
Example Parameters
Returns
Example
shh_getFilterChanges
Parameters
Example Parameters
Returns
Example
shh_getMessages
Parameters
Example Parameters
Returns
Example
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 a 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
See the JavaScript API for more.
JSON-RPC Endpoint
Default JSON-RPC endpoints:
Client | URL |
---|---|
Go | http://localhost:20636 |
Go
You can start the HTTP JSON-RPC with the --rpc
flag
change the default port (20636) and listing address (localhost) with:
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:
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 Hhex EX 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. Here are some 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:
eth_getBalance
eth_getCode
eth_getTransactionCount
eth_getStorageAt
eth_call
The following options are possible for the defaultBlock parameter:
HEX String
- an integer block numberString "earliest"
for the earliest/genesis blockString "latest"
- for the latest mined blockString "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 don't include the URL/IP & port combination, which must be the last argument given to curl e.x. 127.0.0.1:20636
JSON-RPC methods
web3_clientVersion
web3_sha3
net_version
net_peerCount
net_listening
eth_protocolVersion
eth_syncing
eth_coinbase
eth_mining
eth_hashrate
eth_gasPrice
eth_accounts
eth_blockNumber
eth_getBalance
eth_getStorageAt
eth_getTransactionCount
eth_getBlockTransactionCountByHash
eth_getBlockTransactionCountByNumber
eth_getUncleCountByBlockHash
eth_getUncleCountByBlockNumber
eth_getCode
eth_sign
eth_sendTransaction
eth_sendRawTransaction
eth_call
eth_estimateGas
eth_getBlockByHash
eth_getBlockByNumber
eth_getTransactionByHash
eth_getTransactionByBlockHashAndIndex
eth_getTransactionByBlockNumberAndIndex
eth_getTransactionReceipt
eth_pendingTransactions
eth_getUncleByBlockHashAndIndex
eth_getUncleByBlockNumberAndIndex
eth_getCompilers
eth_compileLLL
eth_compileSolidity
eth_compileSerpent
eth_newFilter
eth_newBlockFilter
eth_newPendingTransactionFilter
eth_uninstallFilter
eth_getFilterChanges
eth_getFilterLogs
eth_getLogs
eth_getWork
eth_submitWork
eth_submitHashrate
eth_getProof
db_putString
db_getString
db_putHex
db_getHex
shh_post
shh_version
shh_newIdentity
shh_hasIdentity
shh_newGroup
shh_addToGroup
shh_newFilter
shh_uninstallFilter
shh_getFilterChanges
shh_getMessages
JSON RPC API Reference
web3_clientVersion
Returns the current client version.
Parameters
none
Returns
String
- The current client version.
Example
web3_sha3
Returns Keccak-256 (not the standardized SHA3-256) of the given data.
Parameters
DATA
- the data to convert into a SHA3 hash.
Example Parameters
Returns
DATA
- The SHA3 result of the given string.
Example
net_version
Returns the current network id.
Parameters
none
Returns
String
- The current network id.
"1"
: Elastos.ELA.SideChain.ETH Mainnet"2"
: Morden Testnet (deprecated)"3"
: Ropsten Testnet"4"
: Rinkeby Testnet"42"
: Kovan Testnet
Example
net_listening
Returns true
if client is actively listening for network connections.
Parameters
none
Returns
Boolean
- true
when listening, otherwise false
.
Example
net_peerCount
Returns number of peers currently connected to the client.
Parameters
none
Returns
QUANTITY
- integer of the number of connected peers.
Example
Parameters
none
Example
eth_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 eth_blockNumberhighestBlock
:QUANTITY
- The estimated highest block
Example
eth_coinbase
Returns the client coinbase address.
Parameters
none
Returns
DATA
, 20 bytes - the current coinbase address.
Example
eth_mining
Returns true
if client is actively mining new blocks.
Parameters
none
Returns
Boolean
- returns true
of the client is mining, otherwise false
.
Example
eth_hashrate
Returns the number of hashes per second that the node is mining with.
Parameters
none
Returns
QUANTITY
- number of hashes per second.
Example
eth_gasPrice
Returns the current price per gas in wei.
Parameters
none
Returns
QUANTITY
- integer of the current gas price in wei.
Example
eth_accounts
Returns a list of addresses owned by client.
Parameters
none
Returns
Array of DATA
, 20 Bytes - addresses owned by the client.
Example
eth_blockNumber
Returns the number of most recent block.
Parameters
none
Returns
QUANTITY
- integer of the current block number the client is on.
Example
eth_getBalance
Returns the balance of the account of given address.
Parameters
DATA
, 20 Bytes - address to check for balance.QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter
Example Parameters
Returns
QUANTITY
- integer of the current balance in wei.
Example
eth_getStorageAt
Returns the value from a storage position at a given address.
Parameters
DATA
, 20 Bytes - address of the storage.QUANTITY
- integer of the position in the storage.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 0x295a70b2de5e3953354a6a8344e616ed314d7251
by address 0x391694e7e0b0cce554cb130d723a9d27458f9298
.
Retrieving the value of pos0 is straightforward:
Retrieving an element of the map is harder. The position of an element in the map is calculated with:
This means to retrieve the storage on pos1["0x391694e7e0b0cce554cb130d723a9d27458f9298"] we need to calculate the position with:
The geth console, which comes with the web3 library can be used to make the calculation:
Now to fetch the storage:
eth_getTransactionCount returns the number of transactions sent from an address.
Parameters
DATA
, 20 Bytes - address.QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter
Example Parameters
Returns
QUANTITY
- integer of the number of transactions send from this address.
Example
eth_getBlockTransactionCountByHash
Returns the number of transactions in a block from a block matching the given block hash.
Parameters
DATA
, 32 Bytes - hash of a block.
Example Parameters
Returns
QUANTITY
- integer of the number of transactions in this block.
Example
eth_getBlockTransactionCountByNumber
Returns the number of transactions in a block matching the given block number.
Parameters
QUANTITY|TAG
- integer of a block number, or the string"earliest"
,"latest"
or"pending"
, as in the default block parameter.
Example Parameters
Returns
QUANTITY
- integer of the number of transactions in this block.
Example
eth_getUncleCountByBlockHash
Returns the number of uncles in a block from a block matching the given block hash.
Parameters
DATA
, 32 Bytes - hash of a block.
Example Parameters
Returns
QUANTITY
- integer of the number of uncles in this block.
Example
eth_getUncleCountByBlockNumber
Returns the number of uncles in a block from a block matching the given block number.
Parameters
QUANTITY|TAG
- integer of a block number, or the string "latest", "earliest" or "pending", see the default block parameter.
Returns
QUANTITY
- integer of the number of uncles in this block.
Example
eth_getCode
Returns code at a given address.
Parameters
DATA
, 20 Bytes - address.QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter.
Example Parameters
Returns
DATA
- the code from the given address.
Example
Parameters
account, message
DATA
, 20 Bytes - address.DATA
, N Bytes - message to sign.
Returns
DATA
: Signature
Example
An example of how to use solidity ecrecover to verify the signature calculated with eth_sign
can be found here. The contract is deployed on the testnet: Ropsten and Rinkeby.
eth_sendTransaction
Creates a new message call transaction or a contract creation, if the data field contains code.
Parameters
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 gasvalue
:QUANTITY
- (optional) Integer of the value sent with this transactionnonce
:QUANTITY
- (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
Example Parameters
Returns
DATA
, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.
Use eth_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract.
Example
eth_sendRawTransaction
Creates new message call transaction or a contract creation for signed transactions.
Parameters
DATA
, The signed transaction data.
Example Parameters
Returns
DATA
, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.
Use eth_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract.
Example
eth_call
Executes a new message call immediately without creating a transaction on the block chain.
Parameters
Object
- The transaction call object
from
:DATA
, 20 Bytes - (optional) Tdhe 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. eth_call consumes zero gas, but this parameter may be needed by some executions.gasPrice
:QUANTITY
- (optional) Integer of the gasPrice used for each paid gasvalue
:QUANTITY
- (optional) Integer of the value sent with this transaction
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
eth_estimateGas
Generates and returns an estimate of how much gas is necessary to allow the transaction to completed. 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 (Ethereum Virtual Machine) mechanics and node performance.
Parameters
See eth_call parameters, expect that all properties are optional. If no gas limit is specified, geth uses the block gas limit from the pending block as an upper bound. As a result, the returned estimate might not be enough to execute the call/transaction when the amount of gas is higher than the pending block gas limit.
Returns
QUANTITY
- the amount of gas used.
Example
eth_getBlockByHash
Returns information about a block by hash.
Parameters
DATA
, 32 Bytes - Hash of a block.Boolean
- Iftrue
it returns the full transaction objects, iffalse
only the hashes of the transactions.
Example Parameters
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
eth_getBlockByNumber
Returns information about a block by block number.
Parameters
QUANTITY|TAG
- integer of a block number, or the string"earliest"
,"latest"
or"pending"
, as in the default block parameter.Boolean
- Iftrue
it returns the full transaction objects; iffalse
only the hashes of the transactions.
Example Parameters
Returns
See eth_getBlockByHash
Example
Result see eth_getBlockByHash
eth_getTransactionByHash
Returns the information about a transaction requested by transaction hash.
Parameters
DATA
, 32 Bytes - hash of a transaction
Example Parameters
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 idr
:QUANTITY
- ECDSA signature rs
:QUANTITY
- ECDSA signature s
Example
eth_getTransactionByBlockHashAndIndex
Returns information about a transaction by block hash and index position.
Parameters
DATA
, 32 Bytes - hash of a block.QUANTITY
- integer of the transaction index position.
Example Parameters
Returns
See eth_getTransactionByHash
Example
Result see eth_getTransactionByHash
eth_getTransactionByBlockNumberAndIndex
Returns information about a transaction by block number and index position.
Parameters
QUANTITY|TAG
- a block number, or the string"earliest"
,"latest"
or"pending"
, as in the default block parameter.QUANTITY
- the transaction index position.
Example Parameters
Returns
See eth_getTransactionByHash
Example
Result see eth_getTransactionByHash
eth_getTransactionReceipt
Returns the receipt of a transaction by its hash.
Please note: The receipt is not available for pending transactions.
Parameters
DATA
, 32 Bytes - hash of a transaction
Example Parameters
Returns
Object
- A transaction receipt object, or null
when no receipt was found:
transactionHash
:DATA
, 32 Bytes - transaction hash.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, otherwisenull
.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
either1
(success) or0
(failure)
Example
eth_pendingTransactions
Returns the list of pending transactions.
Parameters
None
Returns
Array
- A list of pending transactions.
Example
eth_getUncleByBlockHashAndIndex
Returns information about a uncle of a block by hash and uncle index position.
Parameters
DATA
, 32 Bytes - hash a block.QUANTITY
- the uncle's index position.
Returns
See eth_getBlockByHash
Example
Result see eth_getBlockByHash
Note: An uncle doesn't contain individual transactions.
eth_getUncleByBlockNumberAndIndex
Returns information about a uncle of a block by number and uncle index position.
Parameters
QUANTITY|TAG
- a block number, or the string"earliest"
,"latest"
or"pending"
, as in the default block parameter.QUANTITY
- the uncle's index position.
Example Parameters
Returns
See eth_getBlockByHash
Note: An uncle doesn't contain individual transactions.
Example
Result see eth_getBlockByHash
eth_getCompilers (DEPRECATED)
Returns a list of available compilers in the client.
Parameters
None
Returns
Array
- Array of available compilers.
Example
eth_compileSolidity (DEPRECATED)
Returns compiled solidity code.
Parameters
String
- The source code.
Example Parameters
Returns
DATA
- The compiled source code.
Example
eth_compileLLL (DEPRECATED)
Returns compiled LLL code.
Parameters
String
- The source code.
Example Parameters
Returns
DATA
- The compiled source code.
Example
eth_compileSerpent (DEPRECATED)
Returns compiled serpent code.
Parameters
String
- The source code.
Example Parameters
Returns
DATA
- The compiled source code.
Example
eth_newFilter
Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call eth_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
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 BytesDATA
topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
Example Parameters
Returns
QUANTITY
- A filter id.
Example
eth_newBlockFilter
Creates a filter in the node in order to notify when a new block arrives. To check if the state has changed, call eth_getFilterChanges.
Parameters
None
Returns
QUANTITY
- A filter id.
Example
eth_newPendingTransactionFilter
Creates a filter in the node to notify when new pending transactions arrive. To check if the state has changed, call eth_getFilterChanges.
Parameters
None
Returns
QUANTITY
- A filter id.
Example
eth_uninstallFilter
Uninstalls a filter with given ID. This should always be called when watch is no longer needed. Additonally, filters time out when they aren't requested with eth_getFilterChanges for a period of time.
Parameters
QUANTITY
- The filter ID.
Example Parameters
Returns
Boolean
- true
if the filter was successfully uninstalled, otherwise false
.
Example
eth_getFilterChanges
Polling method for a filter, which returns an array of logs which occurred since last poll.
Parameters
QUANTITY
- the filter id.
Example Parameters
Returns
Array
- Array of log objects, or an empty array if nothing has changed since last poll.
For filters created with
eth_newBlockFilter
the return are block hashes (DATA
, 32 Bytes), e.g.["0x3454645634534..."]
.For filters created with
eth_newPendingTransactionFilter
the return are transaction hashes (DATA
, 32 Bytes), e.g.["0x6345343454645..."]
.For filters created with
eth_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 BytesDATA
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 theanonymous
specifier.)
Example
eth_getFilterLogs
Returns an array of all logs matching filter with given ID.
Parameters
QUANTITY
- The filter.
Example Parameters
Returns
See eth_getFilterChanges
Example
Result see eth_getFilterChanges
eth_getLogs
Returns an array of all logs matching a given filter object.
Parameters
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 BytesDATA
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 (Geth >= v1.8.13 or Parity >= v2.1.0),blockHash
is a new filter option which restricts the logs returned to the single block with the 32-byte hashblockHash
. UsingblockHash
is equivalent tofromBlock
=toBlock
= the block number with hashblockHash
. IfblockHash
is present in the filter criteria, then neitherfromBlock
nortoBlock
are allowed.
Example Parameters
Returns
See eth_getFilterChanges
Example
Result see eth_getFilterChanges
eth_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:
DATA
, 32 Bytes - current block header pow-hashDATA
, 32 Bytes - the seed hash used for the DAG.DATA
, 32 Bytes - the boundary condition ("target"), 2^256 / difficulty.
Example
eth_submitWork
Used for submitting a Proof-of-Work solution.
Parameters
DATA
, 8 Bytes - The nonce found (64 bits)DATA
, 32 Bytes - The header's pow-hash (256 bits)DATA
, 32 Bytes - The mix digest (256 bits)
Example Parameters
Returns
Boolean
- returns true
if the provided solution is valid, otherwise false
.
Example
eth_submitHashrate
Used for submitting mining hashrate.
Parameters
Hashrate
, a hexadecimal string representation (32 bytes) of the hash rateID
, String - A random hexadecimal(32 bytes) ID identifying the client
Example Parameters
Returns
Boolean
- returns true
if submitting went through succesfully and false
otherwise.
Example
eth_getProof
Returns the account and storage values of the specified account, including the Merkle-proof.
getProof-Parameters
DATA
, 20 bytes - address of the account or contractARRAY
, 32 Bytes - array of storage-keys which should be proofed and included. See eth_getStorageAtQUANTITY|TAG
- integer block number, or the string "latest" or "earliest", see the default block parameter
Example Parameters
getProof-Returns
Returns Object
- A account object:
balance
: QUANTITY
- the balance of the account. See eth_getBalance
codeHash
: DATA
, 32 Bytes - hash of the code of the account. For a simple Account without code it will return "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
nonce
: QUANTITY
, - nonce of the account. See eth_getTransactionCount
storageHash
: DATA
, 32 Bytes - SHA3 of the StorageRoot. All storage will deliver a MerkleProof starting with this rootHash.
accountProof
: ARRAY
- Array of rlp-serialized MerkleTree-Nodes, starting with the stateRoot-Node, following the path of the SHA3 (address) as key.
storageProof
: ARRAY
- Array of storage-entries as requested. Each entry is a object with these properties:
key
: QUANTITY
- the requested storage key value
: QUANTITY
- the storage value proof
: ARRAY
- Array of rlp-serialized MerkleTree-Nodes, starting with the storageHash-Node, following the path of the SHA3 (key) as path.
getProof-Example
db_putString
Stores a string in the local database.
Please note: This function is deprecated and will be removed in the future.
Parameters
String
- Database name.String
- Key name.String
- String to store.
Example Parameters
Returns
Boolean
- returns true
if the value was stored, otherwise false
.
Example
db_getString
Returns string from the local database.
Please note: This function is deprecated and will be removed in the future.
Parameters
String
- Database name.String
- Key name.
Example Parameters
Returns
String
- The previously stored string.
Example
db_putHex
Stores binary data in the local database.
Please note: This function is deprecated and will be removed in the future.
Parameters
String
- Database name.String
- Key name.DATA
- The data to store.
Example Parameters
Returns
Boolean
- returns true
if the value was stored, otherwise false
.
Example
db_getHex
Returns binary data from the local database.
Please note: This function is deprecated and will be removed in the future.
Parameters
String
- Database name.String
- Key name.
Example Parameters
Returns
DATA
- The previously stored data.
Example
shh_version
Returns the current whisper protocol version.
Parameters
none
Returns
String
- The current whisper protocol version.
Example
shh_post
Sends a whisper message.
Parameters
Object
- The whisper post object:
from
:DATA
, 60 Bytes - (optional) The identity of the sender.to
:DATA
, 60 Bytes - (optional) The identity of the receiver. When present whisper will encrypt the message so that only the receiver can decrypt it.topics
:Array of DATA
- Array ofDATA
topics, for the receiver to identify messages.payload
:DATA
- The payload of the message.priority
:QUANTITY
- The integer of the priority in a range from ... (?).ttl
:QUANTITY
- integer of the time to live in seconds.
Example Parameters
Returns
Boolean
- returns true
if the message was send, otherwise false
.
Example
shh_newIdentity
Creates new whisper identity in the client.
Parameters
None
Returns
DATA
, 60 Bytes - the address of the new identity.
Example
shh_hasIdentity
Checks if the client hold the private keys for a given identity.
Parameters
DATA
, 60 Bytes - The identity address to check.
Example Parameters
Returns
Boolean
- returns true
if the client holds the privatekey for that identity, otherwise false
.
Example
shh_newGroup
Creates a new group.
Parameters
None
Returns
DATA
, 60 Bytes - the address of the new group.
Example
shh_addToGroup
Adds a whisper identity to the group.
Parameters
DATA
, 60 Bytes - The identity address to add to a group.
Example Parameters
Returns
Boolean
- returns true
if the identity was successfully added to the group, otherwise false
.
Example
shh_newFilter
Creates a filter to notify when the client receives whisper message matching the filter options.
Parameters
Object
- The filter options:
to
:DATA
, 60 Bytes - (optional) Identity of the receiver. When present it will try to decrypt any incoming message if the client holds the private key to this identity.topics
:Array of DATA
- Array ofDATA
topics which the incoming message's topics should match. You can use the following combinations:[A, B] = A && B
[A, [B, C]] = A && (B || C)
[null, A, B] = ANYTHING && A && B
null
works as a wildcard
Example Parameters
Returns
QUANTITY
- The newly created filter.
Example
shh_uninstallFilter
Uninstalls a filter with given IDID. This should always be called when watch is no longer needed. Additonally, filters time out when they aren't requested with shh_getFilterChanges for a period of time.
Parameters
QUANTITY
- The filter ID.
Example Parameters
Returns
Boolean
- true
if the filter was successfully uninstalled, otherwise false
.
Example
shh_getFilterChanges
Polling method for whisper filters - returns new messages since the last call of this method.
Please note: Using the shh_getMessages method will reset the buffer for this method so that you won't receive duplicate messages.
Parameters
QUANTITY
- The filter id.
Example Parameters
Returns
Array
- Array of messages received since last poll:
hash
:DATA
, 32 Bytes (?) - The hash of the message.from
:DATA
, 60 Bytes - The sender of the message, if a sender was specified.to
:DATA
, 60 Bytes - The receiver of the message, if a receiver was specified.expiry
:QUANTITY
- Integer of the time in seconds when this message should expire (?).ttl
:QUANTITY
- Integer of the time the message should float in the system in seconds (?).sent
:QUANTITY
- Integer of the unix timestamp when the message was sent.topics
:Array of DATA
- Array ofDATA
topics the message contained.payload
:DATA
- The payload of the message.workProved
:QUANTITY
- Integer of the work this message required before it was send (?).
Example
shh_getMessages
Get all messages matching a filter. Unlike shh_getFilterChanges,
this returns all messages.
Parameters
QUANTITY
- The filter id.
Example Parameters
Returns
See shh_getFilterChanges
Example
Result see shh_getFilterChanges
Last updated