eth_getBlockReceipts RPC Method for Base Chain
The eth_getBlockReceipts
RPC method retrieves all transaction receipts included in a specified block, along with the block header information. This method is particularly useful for batch processing transaction data efficiently on Base.
This method provides a convenient way to fetch multiple transaction receipts in a single API call, improving application performance on Base chain.
Common Use Cases
- Batch Analysis: Efficiently analyze all transactions in a specific block without making separate API calls for each transaction receipt.
- DApp Monitoring: Track events emitted by your smart contracts across all transactions in a block.
- Gas Usage Analysis: Calculate average gas costs or monitor gas trends by analyzing all transactions in sequential blocks.
- Event Indexing: Index all smart contract events from specific blocks for off-chain databases or analytics platforms.
- Transaction Verification: Verify that multiple related transactions were all successfully processed in the same block.
Parameters
blockNumber/blockHash or Tag
[required] - String
Hexadecimal block number, block hash, or one of the special tags: "latest", "earliest", "pending"
For example:
- Block number:
"0x1a0d35"
(hex format of block 1723701) - Block hash:
"0x7d704f2c45e395f59fc61c5f451f88c7cb3cd7f1a88fec8f532b51f6cef0383b"
- Special tag:
"latest"
(most recent block)
Read more about block parameter descriptions (opens in a new tab) for additional context.
Returns
-
An array of objects
-
blockNumber
- The number of the block containing these receipts. -
blockHash
32 Bytes - The hash of the block containing these receipts. Returns null when pending. -
contractAddress
- The address of the created contract if the transaction was a contract creation, null otherwise. -
effectiveGasPrice
- The final gas price of the transaction after all fee calculations. -
cumulativeGasUsed
- The total amount of gas used by all transactions in this block up to and including this transaction. -
from
- The sender's address for this transaction. -
gasUsed
- The amount of gas used specifically by this transaction. -
logs
- Array - The event logs generated during this transaction execution.address
- The contract address that generated this log.data
- Non-indexed log parameters, hex encoded.topics
- Array of up to four 32 Bytes DATA of indexed log parameters. In Solidity, the first topic is typically the event signature hash.blockNumber
- The block number containing the transaction that generated this log. Null for pending transactions.transactionHash
- The hash of the transaction that generated this log. Null for pending transactions.transactionIndex
- The position of the transaction in the block. Null for pending transactions.blockHash
- The hash of the block containing this log. Null for pending transactions.logIndex
- The index position of the log in the block. Null for pending transactions.removed
- Boolean indicating if this log was removed due to a chain reorganization (true) or not (false).
-
logsBloom
- The bloom filter bitmap for the logs in this block. -
status
- Transaction execution status: 1 for success, 0 for failure. -
to
- The recipient address of the transaction. Returns null for contract creation transactions. -
transactionHash
- The hash of this transaction. -
transactionIndex
- The index position of this transaction in the block. -
type
- The transaction type identifier.
-
Understanding the Response
Each object in the returned array represents a transaction receipt with detailed information:
- If
status
is0x1
, the transaction executed successfully - If
contractAddress
is not null, the transaction created a new contract at that address - The
logs
array contains all events emitted during transaction execution - Each log's
topics
array typically contains the event signature as the first element, followed by indexed parameters
Request
POST https://base-mainnet.chainnodes.org/YOUR-API-KEY
💡 Confusing?
Ask our experienced blockchain developers in Telegram
Examples
Need help with Base chain development? Join our Chainnodes Telegram Chat (opens in a new tab)
- HTTPS POST Request with a JSON RPC call in the body
- Replace YOUR-API-KEY with the API key from your Chainnodes.org Dashboard
- This example uses the Base chain endpoint
curl https://base-mainnet.chainnodes.org/YOUR-API-KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getBlockReceipts","params": ["0x1a0d35",false],"id":1}'
Example Response
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"blockHash":"0x7d704f2c45e395f59fc61c5f451f88c7cb3cd7f1a88fec8f532b51f6cef0383b",
"blockNumber":"0x1a0d35",
"contractAddress":null,
"cumulativeGasUsed":"0x15213",
"effectiveGasPrice":"0x5f5e100",
"from":"0x87a95fa0e2039aeb57c677aeec64a1153befcbbc",
"gasUsed":"0x15213",
"logs":[
{
"address":"0x4200000000000000000000000000000000000006",
"topics":[
"0x69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2",
"0x000000000000000000000000b9cb4be1052f378972ac5b3e019c809ffb0dedde"
],
"data":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000",
"blockNumber":"0x1a0d35",
"transactionHash":"0x8931b7c96ff5b7269c83d5b2b21659a6cae3c2b7b73e32178305b4d4c8d941d3",
"transactionIndex":"0x0",
"blockHash":"0x7d704f2c45e395f59fc61c5f451f88c7cb3cd7f1a88fec8f532b51f6cef0383b",
"logIndex":"0x0",
"removed":false
}
],
"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status":"0x1",
"to":"0x4200000000000000000000000000000000000006",
"transactionHash":"0x8931b7c96ff5b7269c83d5b2b21659a6cae3c2b7b73e32178305b4d4c8d941d3",
"transactionIndex":"0x0",
"type":"0x2"
}
// Additional transaction receipts would appear here...
]
}
Practical Code Example
Here's how you might use this method in a JavaScript application:
// Function to fetch all transaction receipts in a block
async function getBlockReceipts(blockNumber) {
// Convert block number to hex
const blockHex = '0x' + blockNumber.toString(16);
const response = await fetch('https://base-mainnet.chainnodes.org/YOUR-API-KEY', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_getBlockReceipts',
params: [blockHex, false],
id: 1
})
});
const data = await response.json();
if (data.error) {
throw new Error(`Error fetching block receipts: ${data.error.message}`);
}
return data.result;
}
// Example usage
async function analyzeBlockTransactions(blockNumber) {
try {
const receipts = await getBlockReceipts(blockNumber);
console.log(`Found ${receipts.length} transactions in block ${blockNumber}`);
// Count successful vs failed transactions
const successful = receipts.filter(r => r.status === '0x1').length;
console.log(`Successful transactions: ${successful}`);
console.log(`Failed transactions: ${receipts.length - successful}`);
// Calculate total gas used in this block
const totalGasUsed = receipts.reduce((sum, receipt) => {
return sum + parseInt(receipt.gasUsed, 16);
}, 0);
console.log(`Total gas used in block: ${totalGasUsed}`);
// Count contract creations
const contractCreations = receipts.filter(r => r.contractAddress !== null).length;
console.log(`Contract deployments: ${contractCreations}`);
} catch (error) {
console.error(error);
}
}
// Run the analysis for block 1723701
analyzeBlockTransactions(1723701);
Need RPC API keys?
Get 12.5M archival requests for free today.