Getting started with TheRPC
Ethereum/Core API/eth_feeHistory

eth_feeHistory

The eth_feeHistory method returns historical gas fee data, enabling analysis of network fee trends and helping to make informed decisions about transaction gas prices. This method became essential after the implementation of EIP-1559, which introduced a new fee market mechanism with base fees and priority fees.

Use Cases

  • Gas fee optimization for cost-effective transactions
  • Historical fee analysis for wallet applications
  • Transaction timing optimization based on fee patterns
  • DApp fee estimation for better user experience
  • MEV (Maximal Extractable Value) analysis and strategy
  • Gas price prediction models and algorithms
  • Fee visualization tools and dashboards
  • Economic analysis of network usage patterns

Method Details

This method retrieves a collection of historical gas information, including base fees, gas utilization ratios, and priority fees (tips) at specified percentiles.

Parameters:

Number of blocks in the requested range (1-1024)

Highest block number of the range or block tag

List of percentiles for priority fee calculation

Returns:

Hex string of the oldest block in range

Array of base fees per gas (includes next block)

Array of block gas used ratios

Array of priority fee percentile values

Response Example

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": {
		"oldestBlock": "0x1B177F5",
		"baseFeePerGas": ["0x12", "0x10", "0x11", "0xf", "0xe"],
		"gasUsedRatio": [0.5232, 0.4521, 0.4814, 0.2891],
		"reward": [
			["0x12", "0x34"],
			["0x11", "0x38"],
			["0x15", "0x42"],
			["0x13", "0x39"]
		]
	}
}

Understanding the Response

  • oldestBlock: The starting block number of the historical range
  • baseFeePerGas: Base fees for each block in the range (plus the next block's estimate)
  • gasUsedRatio: How full each block was (0.0-1.0), which affects future base fees
  • reward: Priority fee values at requested percentiles, useful for determining competitive tips

The base fee changes according to network congestion: it increases when blocks are more than 50% full and decreases when less than 50% full. Understanding this mechanism helps predict future fees.

Common Use Case Example

// Example of calculating average base fee from history
const blockCount = 10;
const result = await provider.send('eth_feeHistory', [blockCount, 'latest', [25, 75]]);
const baseFees = result.baseFeePerGas.map((hex) => parseInt(hex, 16));
const avgBaseFee = baseFees.reduce((a, b) => a + b) / baseFees.length;

See also

Help Us Get Better!
Share this page and help us create an even better product for you.