eth_getUncleByBlockHashAndIndex
https://api.triport.io/v1/ethereumReturns the uncle (ommer) block at a given index within a block addressed by its 32-byte hash, or `null` if there is no uncle at that position.
eth_getUncleByBlockHashAndIndex looks up an uncle block (also called an
ommer) by the hash of the block that references it and the uncle's position in
that block's uncles array. It returns a block header object describing the
uncle, or null when the index is out of range or the referencing block is
unknown to the node.
Uncles only exist on the pre-Merge, proof-of-work chain. Before the Merge, two
miners could produce a valid block at the same height; the canonical chain
included one and could reward the other as an uncle. After the Merge
(September 2022), Ethereum's proof-of-stake consensus produces exactly one block
per slot, so post-Merge blocks have no uncles. For any block at or after the
Merge this method returns null, and the uncles array on such blocks is
always empty.
The returned object is a block header — it carries the uncle's own hash, number, miner, and roots, but it does not include the uncle's transactions (uncle transactions are never executed or rewarded).
Parameters
Positional params array: [blockHash, uncleIndex].
blockHashstring (32-byte hex)required0x-prefixed (66 characters total).uncleIndexstring (hex)requireduncles array, encoded as a 0x-prefixed hex quantity (e.g. "0x0" for the first uncle).Response
For a pre-Merge block that has an uncle at the requested index, result is the
uncle's block-header object:
For a post-Merge block, an out-of-range index, or an unknown block hash, the
call succeeds with result: null:
{
"jsonrpc": "2.0",
"id": 1,
"result": null
}numberstring (hex)hashstring (hex)parentHashstring (hex)noncestring (hex)sha3Unclesstring (hex)logsBloomstring (hex)transactionsRootstring (hex)stateRootstring (hex)receiptsRootstring (hex)minerstring (hex)difficultystring (hex)totalDifficultystring (hex)extraDatastring (hex)sizestring (hex)gasLimitstring (hex)gasUsedstring (hex)timestampstring (hex)Errors
| Code | Meaning | When it happens |
|---|---|---|
-32001 | trial_expired | The API key's trial period has ended; upgrade to a paid tier to continue. |
-32003 | rate_limited | Per-tier RPS limit exceeded (10 / 20 / 100 / 250 RPS for free / basic / pro / business). Back off and retry after retry_after_sec. |
-32602 | Invalid params | blockHash is not a 32-byte hex string, or uncleIndex is missing or not a hex quantity. |
A missing uncle, an out-of-range index, and a post-Merge block are not
errors — the call returns result: null. Every error follows the shared
JSON-RPC error envelope — see Errors for the full structure
and handling guidance.
Examples
JavaScript (fetch)
const res = await fetch("https://api.triport.io/v1/ethereum", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "eth_getUncleByBlockHashAndIndex",
params: [
"0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
"0x0",
],
}),
});
const { result: uncle } = await res.json();
if (uncle === null) {
console.log("no uncle at that index (post-Merge blocks never have uncles)");
} else {
console.log(`uncle #${BigInt(uncle.number)} mined by ${uncle.miner}`);
}TypeScript SDK (@triport/sdk)
import { Triport } from "@triport/sdk";
const triport = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });
const uncle = await triport.ethereum.getUncleByBlockHashAndIndex(
"0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
0, // uncle index — encoded as the hex quantity "0x0" on the wire
);
if (uncle) {
console.log(`uncle #${BigInt(uncle.number)} mined by ${uncle.miner}`);
}Python (triport-sdk)
import os
from triport import Triport
triport = Triport(api_key=os.environ["TRIPORT_API_KEY"])
uncle = triport.ethereum.get_uncle_by_block_hash_and_index(
"0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
0,
)
if uncle is not None:
print(f"uncle #{int(uncle['number'], 16)} mined by {uncle['miner']}")Notes
- Post-Merge blocks have no uncles. Proof-of-stake produces one block per
slot, so for any block at or after the Merge this method always returns
null. Uncles are only present on the historical proof-of-work chain. nullis not an error. An out-of-range index or an unknown block hash returnsresult: null. Guard for it before reading any field.- Header only, no transactions. The returned object is the uncle's header; it has no transaction list because uncle transactions are never executed.
- Find the count first. Use
eth_getUncleCountByBlockHashto learn how many uncles a block has before indexing into them. - Related methods:
eth_getUncleByBlockNumberAndIndex,eth_getBlockByHash,eth_getUncleCountByBlockHash.