🔵 Base
eth_getTransactionByBlockNumberAndIndex

🔍 eth_getTransactionByBlockNumberAndIndex - Base Chain JSON-RPC Method

📝 Overview

The eth_getTransactionByBlockNumberAndIndex method retrieves detailed information about a transaction from the Base blockchain by specifying a block number (or tag) and the transaction's position (index) within that block. This method is particularly useful for transaction analysis and building block explorers.

💡 Time-Based Retrieval: Unlike eth_getTransactionByHash, this method allows you to retrieve transactions by their position in a specific block, enabling sequential analysis of transactions as they were processed.

⚙️ Parameters

ParameterTypeDescription
blockNumber or TagStringBlock number (hex) or tag: "latest", "earliest", "pending"
indexStringThe position of the transaction in the block (hex-encoded integer)

Note: Unlike Ethereum and Arbitrum One chains, the "safe" and "finalized" tags are not available on Base chain.

Need RPC API keys?

Get 12.5M archival requests for free today.

🔄 Returns

Transaction Object with the following fields:

FieldTypeDescription
blockHashString32-byte hash of the block containing this transaction
blockNumberStringBlock number (hex) containing this transaction
fromStringAddress of the sender
gasStringGas provided by the sender (hex)
gasPriceStringGas price provided by the sender in wei (hex)
maxFeePerGasStringMaximum fee per gas set in the transaction (EIP-1559 only)
maxPriorityFeePerGasStringMaximum priority fee per gas (EIP-1559 only)
hashString32-byte transaction hash
inputStringData sent with the transaction
nonceStringNumber of transactions made by sender before this one (hex)
toStringAddress of the receiver (null for contract creation)
transactionIndexStringPosition of the transaction in the block (hex)
valueStringValue transferred in wei (hex)
typeStringTransaction type (0=legacy, 1=EIP-2930, 2=EIP-1559)
accessListArrayList of addresses and storage keys the transaction plans to access
chainIdStringChain ID of the transaction (Base mainnet is 8453)
vStringECDSA recovery ID
rStringECDSA signature r value
sStringECDSA signature s value

🌐 Request

POST https://base-mainnet.chainnodes.org/YOUR-API-KEY

🧪 Example

  • HTTPS POST Request with a JSON RPC call in the body
  • Replace YOUR-API-KEY with the API key from your Chainnodes.org Dashboard
  • You can use a different supported network by replacing base-mainnet
curl https://base-mainnet.chainnodes.org/YOUR-API-KEY \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params": ["0x57e450", "0x0"],"id":1}'

📊 Response

{
   "jsonrpc": "2.0",
   "id": 1,
   "result": {
      "blockHash": "0x54751c3cb4f7c95b249ab5ed702a708a6782cc937b1d399f25be4b40d9e0f5d4",
      "blockNumber": "0x57e450",
      "from": "0xad89a377e302791fb523ffb427f3f480cad3a72c",
      "gas": "0x3362",
      "gasPrice": "0xe12c5d1dc",
      "maxFeePerGas": "0xe12c5d1dc",
      "maxPriorityFeePerGas": "0x5f5e100",
      "hash": "0xf02e0576a830ab37f2eb1c43ed3fbcaa53d84bf5ca985ae60c71f5cac27f4cc3",
      "input": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000642f1f1f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "nonce": "0x1",
      "to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
      "transactionIndex": "0x0",
      "value": "0x0",
      "type": "0x2",
      "accessList": [],
      "chainId": "0x2105",
      "v": "0x0",
      "r": "0x3b4afab91edec37c0cfe9e68f2d65c4c7e9ab23d3453eaa456bdb41e5d22548f",
      "s": "0x217ad72b41a611526a45aae9392affba8114c0bd4c25e8ef7f05cda45ef5cee0"
   }
}

🚀 Use Cases

1️⃣ Block Explorer Development

Implement pagination through transactions in specific blocks for a Base chain block explorer.

// Get transactions for a specific page in a block
function getTransactionsPage(blockNumber, pageSize, pageNumber) {
  const startIndex = pageSize * (pageNumber - 1);
  const transactions = [];
  
  for (let i = 0; i < pageSize; i++) {
    const txIndex = '0x' + (startIndex + i).toString(16);
    // Request each transaction
    const tx = await getTransactionByBlockNumberAndIndex(blockNumber, txIndex);
    if (tx) transactions.push(tx);
    else break; // No more transactions
  }
  
  return transactions;
}

2️⃣ Monitoring First Transactions in Blocks

Track the first transaction in each block to analyze transaction ordering patterns on Base.

// Monitor first transaction in each new block
{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["latest","0x0"],"id":1}

3️⃣ Historical Transaction Analysis

Analyze transaction trends over time by examining transactions at specific block heights.

// Compare transactions at regular block intervals
{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["0x500000","0x0"],"id":1}
{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["0x550000","0x0"],"id":1}
{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["0x600000","0x0"],"id":1}

4️⃣ EIP-1559 Adoption Analysis on Base

Analyze the adoption of EIP-1559 transactions on Base by checking transaction types over time.

// Check transaction type at position 0 across multiple blocks
{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["0x57e000","0x0"],"id":1}
// Check the "type" field in the response (0x2 for EIP-1559)

5️⃣ Fee Market Analysis

Track Base chain's fee market dynamics by analyzing gas prices and priority fees in transactions over time.

// Analyze fee market at a specific block
{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["0x57e450","0x0"],"id":1}
// Extract maxFeePerGas and maxPriorityFeePerGas from the response

🔗 Related Methods

JSON-RPC Base API Documentation by CHAINNODES is based on Reth node client. Contact us if you are interested in specific methods that are only available on geth, besu, Nethermind or Erigon