TriportRPC

eth_getTransactionByBlockNumberAndIndex

Last updated:

`eth_getTransactionByBlockNumberAndIndex` returns a single transaction object selected by two coordinates: the block (by number or block tag) and the transaction's zero-based index within that block. Both the block number and the index are `0x`-prefixed hexadecimal strings.

Use it when you already know a transaction's position in a block — for example when iterating a block's transactions one at a time, when you have the index from a prior `eth_getBlockByNumber` call, or when reconstructing a block body without fetching every transaction at once. If you have the block *hash* rather than its number, use the sibling method `eth_getTransactionByBlockHashAndIndex`. If you have the transaction hash directly, use `eth_getTransactionByHash`.

If the block does not exist, or the index is out of range for that block, the `result` is `null` rather than an error.

Parameters

This method takes no parameters.

Returns

eth_getTransactionByBlockNumberAndIndex return value
FieldType
resultobject

Examples

curl https://<your-endpoint>/ \
  -X POST -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"eth_getTransactionByBlockNumberAndIndex","params":[]}'
const res = await fetch("https://<your-endpoint>/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "id": 1,
  "method": "eth_getTransactionByBlockNumberAndIndex",
  "params": [],
  "jsonrpc": "2.0"
}),
});
const data = await res.json();
import requests
resp = requests.post("https://<your-endpoint>/", json={"id":1,"method":"eth_getTransactionByBlockNumberAndIndex","params":[],"jsonrpc":"2.0"})
print(resp.json())

Usage

  1. Transport: HTTP (JSON-RPC).
  2. Networks: mainnet.
  3. Credit cost: 1 per call.

FAQ

What does eth_getTransactionByBlockNumberAndIndex do?
Returns the transaction at a given position within the block identified by its number or a block tag.
How many credits does eth_getTransactionByBlockNumberAndIndex cost?
eth_getTransactionByBlockNumberAndIndex costs 1 credit(s) per call on Triport by default.
Is eth_getTransactionByBlockNumberAndIndex available over WebSocket?
eth_getTransactionByBlockNumberAndIndex is an HTTP JSON-RPC method.