JSON-RPC Method Reference (Part 2)
Part 1 of the JSON-RPC method reference. Continue with part 2. See the method index.
eth_getBlockByHash
Returns information about a block by hash.
Parameters
DATA, 32 Bytes - Hash of a block.Boolean- Iftrueit returns the full transaction objects, iffalseonly the hashes of the transactions.
Example Parameters
params: [
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
true,
];
Returns
Object - A block object, or null when no block was found:
number:QUANTITY- the block number.nullwhen its pending block.hash:DATA, 32 Bytes - hash of the block.nullwhen its pending block.parentHash:DATA, 32 Bytes - hash of the parent block.nonce:DATA, 8 Bytes - hash of the generated proof-of-work.nullwhen 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.nullwhen 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.cumulativeDifficulty:QUANTITY- integer of the difficulty for this block plus its uncles' difficulties.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":"eth_getBlockByHash","params":["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", true],"id":1}'
// Result
{
"id":1,
"jsonrpc":"2.0",
"result": {
"number": "0x1b4", // 436
"hash": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"parentHash": "0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5",
"nonce": "0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"logsBloom": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff",
"miner": "0x4e65fda2159562a496f9f3522f89122a3088497a",
"difficulty": "0x027f07", // 163591
"cumulativeDifficulty": "0x027f07", // 163591
"totalDifficulty": "0x027f07", // 163591
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"size": "0x027f07", // 163591
"gasLimit": "0x9f759", // 653145
"gasUsed": "0x9f759", // 653145
"timestamp": "0x54e34e8e" // 1424182926
"transactions": [{...},{ ... }]
"uncles": ["0x1606e5...", "0xd5145a9..."]
}
}
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- Iftrueit returns the full transaction objects, iffalseonly the hashes of the transactions.
Example Parameters
params: [
"0x1b4", // 436
true,
];
Returns
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x1b4", true],"id":1}'
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
params: ["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"];
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.nullwhen its pending.blockNumber:QUANTITY- block number where this transaction was in.nullwhen 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.nullwhen its a contract creation transaction.transactionIndex:QUANTITY- integer of the transaction's index position in the block.nullwhen its pending.value:QUANTITY- value transferred in Wei.v:QUANTITY- ECDSA recovery idr:QUANTITY- ECDSA signature rs:QUANTITY- ECDSA signature s
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"],"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"
}
}
eth_getTransactionByBlockHashAndIndex
Returns information about a transaction by block hash and transaction index position.
Parameters
DATA, 32 Bytes - hash of a block.QUANTITY- integer of the transaction index position.
Example Parameters
params: [
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"0x0", // 0
];
Returns
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockHashAndIndex","params":["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x0"],"id":1}'
Result see eth_getTransactionByHash
eth_getTransactionByBlockNumberAndIndex
Returns information about a transaction by block number and transaction 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
params: [
"0x29c", // 668
"0x0", // 0
];
Returns
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["0x29c", "0x0"],"id":1}'
Result see eth_getTransactionByHash
eth_getTransactionReceipt
Returns the receipt of a transaction by transaction hash.
Note That the receipt is not available for pending transactions.
Parameters
DATA, 32 Bytes - hash of a transaction
Example Parameters
params: ["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"];
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, 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.effectiveGasPrice:QUANTITY- The actual value per gas deducted on the transaction.
It also returns either :
root:DATA32 bytes of post-transaction stateroot (pre Byzantium)status:QUANTITYeither1(success) or0(failure)
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],"id":1}'
// Result
{
"id":1,
"jsonrpc":"2.0",
"result": {
transactionHash: '0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238',
transactionIndex: '0x1', // 1
blockNumber: '0xb', // 11
blockHash: '0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b',
cumulativeGasUsed: '0x33bc', // 13244
gasUsed: '0x4dc', // 1244
contractAddress: '0xb60e8dd61c5d32be8058bb8eb970870f07233155', // or null, if none was created
logs: [{
// logs as returned by getFilterLogs, etc.
}, ...],
logsBloom: "0x00...0", // 256 byte bloom filter
status: '0x1',
effectiveGasPrice: '0x64' // 100
}
}
eth_pendingTransactions
Returns the pending transactions submitted by the node operator.
Parameters
none
Returns
Array - A list of pending transactions submitted by the node operator.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_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',
type: '0x0'
},....,{
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',
type: '0x0'
}]
}
eth_getUncleByBlockHashAndIndex
Returns information about an uncle of a block by hash and the uncle index position.
Parameters
DATA, 32 Bytes - hash a block.QUANTITY- the uncle's index position.
params: [
"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b",
"0x0", // 0
];
Returns
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleByBlockHashAndIndex","params":["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x0"],"id":1}'
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
params: [
"0x29c", // 668
"0x0", // 0
];
Returns
Note: An uncle doesn't contain individual transactions.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleByBlockNumberAndIndex","params":["0x29c", "0x0"],"id":1}'
Result see eth_getBlockByHash
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 BytesDATAtopics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
Example Parameters
params: [
{
fromBlock: "0x1",
toBlock: "0x2",
address: "0x8888f1f195afa192cfee860698584c030f4c9db1",
topics: [
"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
null,
[
"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc",
],
],
},
];
Returns
QUANTITY - A filter id.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newFilter","params":[{"topics":["0x0000000000000000000000000000000000000000000000000000000012341234"]}],"id":73}'
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x1" // 1
}
eth_newBlockFilter
Creates a filter in the node, 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
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newBlockFilter","params":[],"id":73}'
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x1" // 1
}
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
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newPendingTransactionFilter","params":[],"id":73}'
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x1" // 1
}
eth_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 eth_getFilterChanges for a period of time.
Parameters
QUANTITY- The filter id.
Example Parameters
params: [
"0xb", // 11
];
Returns
Boolean - true if the filter was successfully uninstalled, otherwise false.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_uninstallFilter","params":["0xb"],"id":73}'
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": true
}
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
params: [
"0x16", // 22
];
Returns
Array - Array of log objects, or an empty array if nothing has changed since last poll.
-
For filters created with
eth_newBlockFilterthe return are block hashes (DATA, 32 Bytes), e.g.["0x3454645634534..."]. -
For filters created with
eth_newPendingTransactionFilterthe return are transaction hashes (DATA, 32 Bytes), e.g.["0x6345343454645..."]. -
For filters created with
eth_newFilterlogs are objects with following params:removed:TAG-truewhen the log was removed, due to a chain reorganization.falseif its a valid log.logIndex:QUANTITY- integer of the log index position in the block.nullwhen its pending log.transactionIndex:QUANTITY- integer of the transactions index position log was created from.nullwhen its pending log.transactionHash:DATA, 32 Bytes - hash of the transactions this log was created from.nullwhen its pending log.blockHash:DATA, 32 Bytes - hash of the block where this log was in.nullwhen its pending.nullwhen its pending log.blockNumber:QUANTITY- the block number where this log was in.nullwhen its pending.nullwhen 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 BytesDATAof 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 theanonymousspecifier.)
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x16"],"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"]
},{
...
}]
}
eth_getFilterLogs
Returns an array of all logs matching filter with given id.
Parameters
QUANTITY- The filter id.
Example Parameters
params: [
"0x16", // 22
];
Returns
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterLogs","params":["0x16"],"id":74}'
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 BytesDATAtopics. 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),blockHashis a new filter option which restricts the logs returned to the single block with the 32-byte hashblockHash. UsingblockHashis equivalent tofromBlock=toBlock= the block number with hashblockHash. IfblockHashis present in the filter criteria, then neitherfromBlocknortoBlockare allowed.