eth_getBlockReceipts | Ethereum
Ethereum API method that retrieves all transaction receipts for a given block. Transaction receipts contain information about the execution status of a transaction and can be useful for monitoring the status of transfers or contract execution on the blockchain.
This method is available on both the Geth and Erigon clients.
Get you own node endpoint today
Start for free and get your app to production levels immediately. No credit card required.
You can sign up with your GitHub, X, Google, or Microsoft account.
Parameters
-
quantity or tag
— the integer of a block encoded as hexadecimal or the string with:latest
— the most recent block in the blockchain and the current state of the blockchain at the most recent block. A chain reorganization is to be expected.safe
— the block that received justification from the beacon chain. Although this block could be involved in a chain reorganization, it would necessitate either a coordinated attack by the majority of validators or an instance of severe propagation latency.finalized
— the block accepted as canonical by more than 2/3 of the validators. A chain reorganization is extremely unlikely, and it would require at least 1/3 of the staked ETH to be burned.earliest
— the earliest available or genesis blockpending
— the pending state and transactions block. The current state of transactions that have been broadcast to the network but have not yet been included in a block.
Response
result
— an array of objects with the following fields:Transaction receipt
— the object with:blockHash
— the block hash. Identifies the block in which the transaction was included. This field isnull
for transactions that have not yet been included in a block.blockNumber
— the number of the block in which the transaction was included. This field isnull
for transactions that have not yet been included in a block.contractAddress
— the address of the contract created by the transaction if it was a contract creation transaction. Otherwise, the value isnull
.cumulativeGasUsed
— the total amount of gas used in the block until this transaction was executed.effectiveGasPrice
— the actual value deducted from the sender’s account for this transaction.from
— the address of the sender who initiated the transaction.gasUsed
— the amount of gas used by this specific transaction alone.logs
— an array of log objects generated by this transaction, if any. Logs are generated by smart contracts.logsBloom
— the bloom filter used by light clients to quickly retrieve logs related to the transaction.status
— the success status of the transaction, represented as1
for success or0
for failure.to
— the address of the recipient of the transaction if it was a transaction to an address. For contract creation transactions, this field isnull
.transactionHash
— the hash that uniquely identifies the transaction.transactionIndex
— the index of the transaction within the block.type
— the type of the transaction.0
indicates a regular transfer;2
indicates a contract creation or smart contract function call.
eth_getBlockReceipts
code examples
Learn more about the ChainstackProvider
in ethers.js
: ethers ChainstackProvider Documentation.
Use case
The eth_getBlockReceipts
allows you to retrieve the receipts for all transactions in a specific block. A practical use case can be to retrieve all of the logs emitted from the transactions in a block. The method returns an array of transaction receipts containing information about the transaction and any logs generated due to the transaction execution, so the logs can be isolated.
Read Uncovering the power of eth_getBlockReceipts to learn more about transactions receipts and how to use the eth_getBlockReceipts
method.
Here is an example of how to use eth_getBlockReceipts
in ethers.js using the ChainstackProvider
to extract all of the logs in a specific block and return them in an array:
In this example, the retrieveTransactionLogs
function takes a block identifier as an input and returns an array of logs. The function first calls the eth_getBlockReceipts
method using the provider.send
method and passes in the block identifier as an argument. The result is an array of receipts, then flattened into a single array of logs using the flatMap
function.