Ethereum

Ethereum

eth_getUncleCountByBlockNumber

eth_getUncleCountByBlockNumber returns how many uncles a block references, addressed by height or by a tag such as latest, finalized, or earliest. It is the height-keyed counterpart to the hash version, and the one that fits a loop incrementing a block number across Ethereum history. The count reflects the chain's consensus era: pre-Merge PoW blocks (below 15537393) can carry up to two uncles and report 0x1 or 0x2, while every PoS block since The Merge reports 0x0 because the protocol no longer mints ommers. The endpoint is https://ethereum.therpc.io/YOUR_API_KEY on chain ID 1, and the result is a hex-encoded integer.

Use cases

  • Walk a sequential height range and sum the counts to derive the uncle rate over a window of Ethereum's PoW years, a metric that tracked how often near-simultaneous blocks were orphaned.
  • Run it as a one-call precheck before eth_getUncleByBlockNumberAndIndex: only fetch headers for heights where the count is non-zero.

Parameters

#NameTypeRequiredDescription
1blockTagstringYesThe block to count uncles in.

Response

TypeDescription
string (hex)Hex-encoded uncle count.

Example request

curl https://ethereum.therpc.io/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getUncleCountByBlockNumber",
"params": ["latest"],
"id": 1
}'

Try it live in the Ethereum playground.

Errors & troubleshooting

CodeMessageCause
-32602Invalid paramsBlock tag is malformed or unrecognised.

Common pitfalls

  • For any block at or above 15537393 the answer is 0x0 no matter which height you pass, because PoS Ethereum never produces uncles. Restrict meaningful queries to the PoW range below that.
  • The value is a hex string, so "0x2" will not compare as the number 2 directly. Parse it (for example parseInt(result, 16)) before doing any arithmetic or threshold check.

Supported networks

  • Mainnet — Chain ID: 1
  • Sepolia — Chain ID: 11155111

See also

Parameters

hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"

curl https://ethereum.therpc.io/YOUR_API_KEY \
-X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"eth_getUncleCountByBlockNumber","params":[""]}'

Ready to call this in production?

Free tier covers personal projects. Pay-as-you-go scales without a card.