eth_getBlockReceipts - Base

The eth_getBlockReceipts method returns all transaction receipts for a given block. This is more efficient than fetching individual receipts when you need all receipts from a block.

Parameters

ParameterTypeRequiredDescription
blockParameterstringYesBlock number in hex, block hash, or "latest", "earliest", "pending"

Request

cURL

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_getBlockReceipts",
    "params": ["latest"],
    "id": "getblock.io"
}'

Axios (JavaScript)

javascriptconst axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'eth_getBlockReceipts',
    params: ['latest'],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

const receipts = response.data.result;
console.log('Total Receipts:', receipts.length);
receipts.forEach(r => {
    console.log('Tx:', r.transactionHash, 'Status:', r.status === '0x1' ? 'Success' : 'Failed');
});

Requests (Python)

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'eth_getBlockReceipts',
        'params': ['latest'],
        'id': 'getblock.io'
    }
)

result = response.json()
receipts = result['result']
print(f'Total Receipts: {len(receipts)}')
for r in receipts:
    status = 'Success' if r['status'] == '0x1' else 'Failed'
    print(f'Tx: {r["transactionHash"]} Status: {status}')

Rust

rustuse reqwest::Client;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    
    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "eth_getBlockReceipts",
            "params": ["latest"],
            "id": "getblock.io"
        }))
        .send()
        .await?
        .json::<Value>()
        .await?;
    
    let receipts = response["result"].as_array().unwrap();
    println!("Total Receipts: {}", receipts.len());
    Ok(())
}

Response

Response (example)

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": [
        {
            "transactionHash": "0x633982a26e0cfba940613c52b31c664fe977e05171e35f62da2426596007e249",
            "transactionIndex": "0x0",
            "blockHash": "0x849a3ac8f0d81df1a645701cdb9f90e58500d2eabb80ff3b7f4e8c13f025eff2",
            "blockNumber": "0x12d687f",
            "from": "0x742d35Cc6634C0532925a3b844Bc9e7595f5bE21",
            "to": "0x1234567890123456789012345678901234567890",
            "cumulativeGasUsed": "0x5208",
            "gasUsed": "0x5208",
            "effectiveGasPrice": "0x5f5e100",
            "contractAddress": null,
            "logs": [],
            "logsBloom": "0x00000000...",
            "status": "0x1",
            "type": "0x2",
            "l1Fee": "0x2540be400",
            "l1GasPrice": "0x3b9aca00",
            "l1GasUsed": "0x640"
        }
    ]
}

Response Parameters

ParameterTypeDescription
transactionHashstring32-byte transaction hash
blockHashstring32-byte block hash
blockNumberstringBlock number in hex
fromstring20-byte sender address
tostring20-byte recipient address
statusstring0x1 for success, 0x0 for failure
gasUsedstringGas used by this transaction (hex)
effectiveGasPricestringActual gas price paid (hex)
logsarrayArray of log objects
l1FeestringL1 data fee (Base-specific)

Use Cases

  1. Block Processing: Process all transactions in a block efficiently.
  2. Event Indexing: Extract all events from a block at once
  3. Analytics: Analyze gas usage across entire blocks.
  4. Chain Indexing: Build block-by-block indexes.
  5. MEV Analysis: Examine transaction ordering and outcomes.

Error Handling

Error CodeMessageDescription
-32602Invalid paramsInvalid block parameter
-32603Internal errorBlock not found or node failure

Web3 Integration

Ethers.js (v6)

javascriptconst { ethers } = require('ethers');

const provider = new ethers.JsonRpcProvider('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');

async function getBlockReceipts(blockNumber = 'latest') {
    const receipts = await provider.send('eth_getBlockReceipts', [blockNumber]);
    
    console.log('Total Receipts:', receipts.length);
    
    let totalGasUsed = 0n;
    receipts.forEach(receipt => {
        totalGasUsed += BigInt(receipt.gasUsed);
        console.log('Tx:', receipt.transactionHash);
        console.log('  Status:', receipt.status === '0x1' ? 'Success' : 'Failed');
        console.log('  Gas Used:', parseInt(receipt.gasUsed, 16));
    });
    
    console.log('Total Block Gas Used:', totalGasUsed.toString());
    return receipts;
}

getBlockReceipts();

Viem

javascriptimport { createPublicClient, http } from 'viem';
import { base } from 'viem/chains';

const client = createPublicClient({
    chain: base,
    transport: http('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/')
});

async function getBlockReceipts(blockNumber = 'latest') {
    const receipts = await client.request({
        method: 'eth_getBlockReceipts',
        params: [blockNumber]
    });
    
    console.log('Total Receipts:', receipts.length);
    
    receipts.forEach(receipt => {
        console.log('Tx:', receipt.transactionHash);
        console.log('  Status:', receipt.status);
        console.log('  Logs:', receipt.logs.length);
    });
    
    return receipts;
}

getBlockReceipts();