Skip to main content

eth_feeHistory

Returns historical gas information on MegaETH for fee estimation.

Use Cases#

  • Fee prediction - Estimate future gas prices based on history
  • Gas analytics - Analyze fee trends over time
  • Optimal timing - Find best times for transactions on high-frequency trading, real-time gaming, instant payments, and latency-sensitive applications

Block Range Limit#

Block Range Limit

On MegaETH, eth_feeHistory queries are subject to a maximum block range of 10,000 blocks. This means the blockCount parameter cannot exceed 10,000 blocks per request.

For querying larger block ranges, split your requests into batches:

// Example: Query in 10,000-block batches
const MAX_RANGE = 10000;
const totalBlocks = 50000;
const newestBlock = await provider.getBlockNumber();

const allFeeHistory = [];

for (let i = 0; i < totalBlocks; i += MAX_RANGE) {
const blockCount = Math.min(MAX_RANGE, totalBlocks - i);
const feeHistory = await provider.send('eth_feeHistory', [
blockCount,
newestBlock - i,
[]
]);
allFeeHistory.push(feeHistory);
}

Parameters#

ParameterTypeRequiredDescription
blockCountQUANTITYYesNumber of blocks in the range
newestBlockQUANTITY|TAGYesHighest block of the range
rewardPercentilesArrayYesPercentiles to sample for priority fees

Request#

{
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": ["0x5", "latest", [25, 50, 75]],
"id": 1
}

Code Examples#

curl -X POST https://api-megaeth-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": ["0x5", "latest", [25, 50, 75]],
"id": 1
}'