eth_getTransactionByBlockNumberAndIndex — Ethereum JSON-RPC
Returns the transaction at a given position within the block identified by its number or a block tag.
https://triport.io/eth- Network
- Ethereum
- Scope
- eth_read_rpc
- Auth
- x-token: $TRIPORT_API_KEY (or Authorization: Bearer)
- Rate limit
- free 10 RPS sustained · up to 20 burst · basic 20 RPS sustained · up to 40 burst · pro 100 RPS sustained · up to 200 burst · business 250 RPS sustained · up to 500 burst; Burst capacity
Endpoint and plans: Ethereum RPC endpoint.
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
Pass a two-element positional array.
blockParameterstringrequired0x-prefixed hex block number (e.g. 0x149e2c1) or a block tag: latest, earliest, pending, safe, or finalized.transactionIndexstringrequired0x-prefixed hex integer (e.g. 0x0 for the first transaction).Response
Response fields
| Field | Type | Description |
|---|---|---|
jsonrpc | string | JSON-RPC version, always "2.0". |
id | number | Echoes the request id. |
result | object | null | The transaction object, or null if the block was not found or the index is out of range. |
The transaction object contains the standard Ethereum fields:
| Field | Type | Description |
|---|---|---|
blockHash | string | Hash of the containing block, or null if pending. |
blockNumber | string | Block number as 0x-prefixed hex, or null if pending. |
from | string | Sender address. |
to | string | null | Recipient address; null for contract-creation transactions. |
gas | string | Gas supplied, hex. |
gasPrice | string | Effective gas price, hex (in wei). |
maxFeePerGas | string | Max fee per gas, hex — present on EIP-1559 (type 0x2) transactions. |
maxPriorityFeePerGas | string | Max priority fee per gas, hex — present on EIP-1559 transactions. |
hash | string | Transaction hash. |
input | string | Call data, hex. |
nonce | string | Sender nonce, hex. |
transactionIndex | string | Index of the transaction in the block, hex. |
value | string | Value transferred in wei, hex. |
type | string | Transaction type (0x0 legacy, 0x1 access-list, 0x2 EIP-1559). |
chainId | string | Chain ID, hex (0x1 for Ethereum mainnet). |
v, r, s | string | ECDSA signature components, hex. |
Errors
| Code | Meaning | When it happens |
|---|---|---|
401 | trial_expired | The account's trial period has ended. |
429 | rate_limited | The per-tier RPS limit was exceeded. Back off and retry. |
-32602 | invalid_params | The block parameter or index is missing, or not a valid hex value / tag. |
See errors.md for the full error envelope and handling guidance.
Examples
JavaScript (fetch)
const res = await fetch("https://triport.io/eth", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "eth_getTransactionByBlockNumberAndIndex",
params: ["latest", "0x0"],
}),
});
const { result } = await res.json();
console.log(result === null ? "no such transaction" : result.hash);Notes
- The index is zero-based:
0x0is the first transaction in the block. - An out-of-range index or a non-existent block returns
result: null, not an error — check fornullbefore reading fields. - Numeric fields (
value,gas,gasPrice,nonce, …) are hex strings; convert with base 16 before arithmetic. eth_getTransactionByBlockNumberAndIndexis available on the Free trial (eth_read_rpccategory).- Rate limiting is RPS-per-tier with burst; there is no daily quota. An
HTTP
429rate_limitederror means you should back off and retry shortly. - To select by block hash instead, use
eth_getTransactionByBlockHashAndIndex. To look up a transaction by its own hash, useeth_getTransactionByHash. To count a block's transactions first, useeth_getBlockTransactionCountByNumber.