Ethereum

Ethereum

eth_feeHistory

eth_feeHistory returns a window of recent fee data from Ethereum mainnet: the protocol baseFeePerGas for each block (the portion of the fee that gets burned under EIP-1559), the gasUsedRatio showing how full each block was, and, when you ask for them, priority-fee tips sampled at the percentiles you specify. Since London the base fee floats with demand — rising when blocks run past the 50% target, falling when they're empty — so a few blocks of history is the raw material for picking sane maxFeePerGas and maxPriorityFeePerGas values on a type-2 transaction. Query it at https://ethereum.therpc.io/YOUR_API_KEY (chain ID 1) and feed the arrays into your fee oracle. All fee figures are in wei of ETH.

Use cases

  • Fee estimator. Take the latest base fee, add a tip read from the 25th/50th/75th reward percentiles, and set maxFeePerGas with headroom for a base-fee climb over the next few slots.
  • Gas trend chart. Plot the baseFeePerGas array over a window so a wallet or explorer can show users whether fees are spiking or cooling.
  • Congestion signal. Watch gasUsedRatio — values pinned near 1.0 across consecutive blocks mean the base fee is about to ratchet up; near zero means it's draining.
  • Tip strategy under competition. Compare low vs high percentiles in the reward arrays to gauge how aggressively others are tipping for priority inclusion, then size your own tip to land in the block you want.

Parameters

#NameTypeRequiredDescription
1blockCountstring | numberYesNumber of blocks to include in the history window. Most providers cap this at 1024.
2newestBlockstringYesThe most recent block to include in the window.Default: latest
3rewardPercentilesnumber[]NoArray of percentile values (0–100) at which to sample priority fees from each block. Pass an empty array to omit reward data.

Response

TypeDescription
objectObject with: `oldestBlock` (hex, starting block of the window), `baseFeePerGas` (array of hex wei — one per block plus the next predicted value), `gasUsedRatio` (array of floats 0–1 per block), `reward` (array of arrays — per-block percentile priority fees in hex wei; only present when `rewardPercen

Example request

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

Try it live in the Ethereum playground.

Errors & troubleshooting

CodeMessageCause
-32602invalid argumentblockCount is 0, out of range, or rewardPercentiles contains values outside 0–100.
-32000block not found`newestBlock` references a block that does not exist on this node.

Common pitfalls

  • The baseFeePerGas array has one more entry than the number of blocks you requested. That trailing element is the protocol-computed base fee for the next block — a forecast, not a mined value — so don't pair it with a real block's data.
  • This is an EIP-1559 method. On a pre-London block range or an EVM chain without 1559 you'll get an error or missing fee fields; on Ethereum mainnet it's been live since August 2021, so only ancient history is affected.
  • Responses scale with blockCount and percentile count. Providers cap the window (commonly 1024); for charts, request 100–200 blocks per call and stitch windows rather than pulling the full cap at once.

Supported networks

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

See also

Parameters

Hex or decimal integer, e.g. "0xa" or 10

"latest" | "safe" | "finalized" | hex block number

Array of percentile values (0–100) at which to sample priority fees from each block. Pass an empty array to omit reward data.

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

Ready to call this in production?

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