Description
Motivation
Currently, the way we obtain complete information about all transactions in a block is as follows:
- Call
eth_getBlockBy{Number,Hash}
to retrieve all transaction data for a block; - Iterate through all the transaction data obtained above and call
eth_getTransactionReceipt
to retrieve the receipt data for each transaction.
This method is highly inefficient for obtaining large amounts of block and transaction data. To make it easier for users, we propose an RPC that returns all the receipt data for a block in one call.
Parity/OpenEthereum(DEPRECATED) has already implemented this method under the parity
namespace(parity_getblockreceipts), and some node providers(eg: alchemy eth_getBlockReceipts) have provided similar solutions. If we can include this RPC in the standard, I believe it would be more consistent and user-friendly for users.
Spec
Here is the spec for eth_getBlockReceiptsBy{Number,Hash}
eth_getBlockReceiptsByNumber {#eth_getBlockReceiptsByNumber}
Returns information about a block receipts by block number.
Parameters
Quantity or Tag
- integer of a block number, or the string 'earliest', 'latest' or 'pending', as in the default block parameter.
params: ["0x1234"]
Returns Array
- The list of Receipt object of the given block:
eg:
{
"id": 1,
"jsonrpc": "2.0",
"result": [
{
"blockHash": "0x64d67cf84d95f8dfa1e1c3b5a5260aaf801ac99529b4ec3ae19bb06ba78c7bd5",
"blockNumber": "0x8d2b29",
"contractAddress": null,
"cumulativeGasUsed": "0x5208",
"from": "0x4d6bb4ed029b33cf25d0810b029bd8b1a6bcab7b",
"gasUsed": "0x5208",
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"root": null,
"status": "0x1",
"to": "0xe9c245293dac615c11a5bf26fcec91c3617645e4",
"transactionHash": "0x1eba82fb5e8426b520c49a5d8dc6c24157e8f45fb9102aca4a99f5617c1539fc",
"transactionIndex": "0x0"
},
{
"blockHash": "0x64d67cf84d95f8dfa1e1c3b5a5260aaf801ac99529b4ec3ae19bb06ba78c7bd5",
"blockNumber": "0x8d2b29",
"contractAddress": null,
"cumulativeGasUsed": "0x3fc28",
"from": "0x0caf0d921b2bd24ca04e1f06344e976af223783b",
"gasUsed": "0x3aa20",
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"root": null,
"status": "0x1",
"to": "0xf2bb17cb59746cae43d65eec233925b6584cddef",
"transactionHash": "0x70a50d28db69e5c7a8686141f282530d52e7e3c625296dc53eb5684afa727886",
"transactionIndex": "0x1"
}
]
}
eth_getBlockReceiptsByHash {#eth_getBlockReceiptsByHash}
Returns information about a block receipts by block hash.
Parameters
DATA
, 32 Bytes - hash of a block
params: ["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"]
Returns Array
- The list of Receipt object of the given block:
eg:
{
"id": 1,
"jsonrpc": "2.0",
"result": [
{
"blockHash": "0x64d67cf84d95f8dfa1e1c3b5a5260aaf801ac99529b4ec3ae19bb06ba78c7bd5",
"blockNumber": "0x8d2b29",
"contractAddress": null,
"cumulativeGasUsed": "0x5208",
"from": "0x4d6bb4ed029b33cf25d0810b029bd8b1a6bcab7b",
"gasUsed": "0x5208",
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"root": null,
"status": "0x1",
"to": "0xe9c245293dac615c11a5bf26fcec91c3617645e4",
"transactionHash": "0x1eba82fb5e8426b520c49a5d8dc6c24157e8f45fb9102aca4a99f5617c1539fc",
"transactionIndex": "0x0"
},
{
"blockHash": "0x64d67cf84d95f8dfa1e1c3b5a5260aaf801ac99529b4ec3ae19bb06ba78c7bd5",
"blockNumber": "0x8d2b29",
"contractAddress": null,
"cumulativeGasUsed": "0x3fc28",
"from": "0x0caf0d921b2bd24ca04e1f06344e976af223783b",
"gasUsed": "0x3aa20",
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"root": null,
"status": "0x1",
"to": "0xf2bb17cb59746cae43d65eec233925b6584cddef",
"transactionHash": "0x70a50d28db69e5c7a8686141f282530d52e7e3c625296dc53eb5684afa727886",
"transactionIndex": "0x1"
}
]
}