eth_feeHistory
The eth_feeHistory method returns historical gas fee information for a range of blocks. This method provides comprehensive fee market data including base fees, gas utilization ratios, and priority fee (tip) statistics at user-specified percentiles, enabling data-driven gas price estimation.
This method is essential for implementing dynamic gas price strategies in wallets and applications, especially for EIP-1559 transactions. By analyzing recent fee history, you can estimate appropriate maxFeePerGas and maxPriorityFeePerGas values that balance transaction speed with cost. The percentile-based reward data helps you understand the distribution of priority fees, allowing you to target specific inclusion probabilities (e.g., 50th percentile for normal speed, 95th for fast). This is far more accurate than using fixed multipliers, as it adapts to real-time network conditions and congestion patterns.
Parameters
parameter | type | description |
|---|---|---|
blockCount | string (required) | Number of blocks in the requested range (hex) |
newestBlock | string (required) | Highest block number to include, in hex or tag (latest, earliest, pending) |
rewardPercentiles | array (optional) | Array of percentile values (0-100) for priority fee stats |
Return Object
The method returns an object containing historical fee data:
field | type | description |
|---|---|---|
oldestBlock | string | The block number of the oldest block in the returned range (hexadecimal) |
baseFeePerGas | array | Array of base fees per gas for each block in the range (hex strings in wei). Length is blockCount + 1, with the last value being the base fee for the next block after the range. For pre-EIP-1559 blocks, these values will be null or zero |
gasUsedRatio | array | Array of gas used ratios for each block. Each value is a floating point number between 0 and 1 representing the fraction of gas used relative to the gas limit (e.g., 0.5 means 50% full). Length is blockCount |
reward | array | Optional array of arrays containing priority fee (tip) percentiles for each block. Only present if rewardPercentiles parameter was provided. Each inner array contains the requested percentile values (in wei, hex-encoded) for that block's transactions |
This data is particularly useful for EIP-1559 fee estimation. The baseFeePerGas helps set maxFeePerGas, while reward percentiles help choose maxPriorityFeePerGas. High gasUsedRatio values indicate network congestion.
Request Example
Response Example