eth_getFeeHistory
Retrieve historical gas fee data to estimate EIP-1559 transaction costs. Specify block range and priority fee percentiles for accurate fee prediction.
Instructions
Get historical gas fee data for EIP-1559 fee estimation.
Args:
blockCount (string): Number of blocks to analyze as hex (e.g., '0x4' for 4 blocks).
newestBlock (string): Latest block to include ('latest', 'pending', or hex block number).
rewardPercentiles (array): Percentiles for priority fee sampling (e.g., [25, 50, 75]).
network (string, optional): Ethereum network to query. Defaults to 'mainnet'.
Returns:
Object with baseFeePerGas array, gasUsedRatio array, oldestBlock, and reward matrix.
Examples:
"Get last 4 blocks fee history": { "blockCount": "0x4", "newestBlock": "latest", "rewardPercentiles": [25, 50, 75] }
"Query Sepolia fees": { "blockCount": "0xa", "newestBlock": "latest", "rewardPercentiles": [10, 50, 90], "network": "sepolia" }
Errors:
InvalidParams: When blockCount format, newestBlock, or rewardPercentiles are invalid.
InternalError: When Infura API is unavailable or returns an error.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blockCount | Yes | The number of blocks to check. | |
| newestBlock | Yes | The latest block number or tag (e.g., 'latest'). | |
| rewardPercentiles | Yes | A list of percentiles for gas rewards. | |
| network | No | The Ethereum network to query, e.g., 'mainnet' or 'sepolia'. | mainnet |
| response_format | No | Output format: 'json' for structured data, 'markdown' for human-readable. | json |