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.