eth_feeHistory - Ethereum

This method returns historical gas fee data over a range of recent blocks. Given a block count, the last block to include, and reward percentiles, it returns the base fee for each block plus priority-fee reward percentiles from included transactions. This is the primary input for well-calibrated EIP-1559 fee estimation strategies used by modern wallets.

Parameters

ParameterTypeRequiredDescription
blockCountstringYesHex-encoded number of blocks to look back (max 1024)
newestBlockstringYesNewest block to include — block number in hex, or latest, earliest, pending, finalized, safe
rewardPercentilesarray of numbersNoPriority-fee percentiles (0-100) to return per block (e.g. [25, 50, 75])

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_feeHistory",
    "params": [
        "0x5",
        "latest",
        [
            25,
            50,
            75
        ]
    ],
    "id": "getblock.io"
}'

example.js

javascriptconst axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'eth_feeHistory',
    params: [
        "0x5",
        "latest",
        [
            25,
            50,
            75
        ]
    ],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'eth_feeHistory',
        'params': [
            "0x5",
            "latest",
            [
                25,
                50,
                75
            ]
        ],
        'id': 'getblock.io'
    }
)

print(response.json())

example.rs

rustuse reqwest::Client;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    
    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "eth_feeHistory",
            "params": [
                "0x5",
                "latest",
                [
                    25,
                    50,
                    75
                ]
            ],
            "id": "getblock.io"
        }))
        .send()
        .await?
        .json::<Value>()
        .await?;
    
    println!("Result: {}", response["result"]);
    Ok(())
}

Response

json{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "result": {
    "oldestBlock": "0x172033c",
    "baseFeePerGas": [
      "0x5f5e100",
      "0x60a3f80",
      "0x5d21dba",
      "0x5b8d7c1",
      "0x5cc4e56",
      "0x5e0c1a3"
    ],
    "gasUsedRatio": [
      0.512,
      0.482,
      0.501,
      0.633,
      0.517,
      0.499
    ],
    "baseFeePerBlobGas": [
      "0x1",
      "0x1",
      "0x1",
      "0x1",
      "0x1",
      "0x1"
    ],
    "blobGasUsedRatio": [
      0.428,
      0.571,
      0.5,
      0.428,
      0.357,
      0.5
    ],
    "reward": [
      [
        "0x3b9aca00",
        "0x77359400",
        "0xba43b7400"
      ],
      [
        "0x3b9aca00",
        "0x77359400",
        "0xba43b7400"
      ],
      [
        "0x3b9aca00",
        "0x77359400",
        "0xba43b7400"
      ],
      [
        "0x3b9aca00",
        "0x77359400",
        "0xba43b7400"
      ],
      [
        "0x3b9aca00",
        "0x77359400",
        "0xba43b7400"
      ]
    ]
  }
}

Response Parameters

ParameterTypeDescription
jsonrpcstringJSON-RPC protocol version ("2.0")
idstringRequest identifier matching the request
result.oldestBlockstringHex-encoded block number of the oldest block in the returned window
result.baseFeePerGasarray of stringBase fee (wei, hex) for each block in the window plus the next block
result.gasUsedRatioarray of numberRatio of gas used to gas limit per block (0.0 - 1.0)
result.baseFeePerBlobGasarray of stringPost-Cancun blob base fee (wei, hex) per block
result.blobGasUsedRatioarray of numberRatio of blob gas used to blob gas target per block (0.0 - 1.0)
result.rewardarray of array of stringPriority-fee percentiles (wei, hex) per block for the requested percentiles

Use Cases

  • Well-Calibrated Fee Estimation: Wallets compute wallet-recommended fees from historical rewards distribution rather than a single-value estimate
  • Congestion Analysis: Detect network congestion from gasUsedRatio and baseFeePerGas trajectory
  • Blob Fee Trend Analysis: Track blob base-fee trajectory and blob-gas-used ratios for L2 cost modeling
  • Historical Fee Charts: Wallet UIs displaying fee-history charts to help users choose an appropriate fee level

Error Handling

Error CodeMessageDescription
-32602Invalid paramsblockCount exceeds 1024, or rewardPercentiles contains non-numeric or out-of-range values
-32603Internal errorNode failed to compile the fee history window

Web3 Integration

ethers-example.js

javascriptimport { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');

const feeHistory = await provider.send('eth_feeHistory', [
    '0x5',       // last 5 blocks
    'latest',    // ending at latest
    [25, 50, 75] // reward percentiles
]);
console.log('Oldest block:', feeHistory.oldestBlock);
console.log('Base fees:', feeHistory.baseFeePerGas);
console.log('Reward percentiles:', feeHistory.reward);

viem-example.js

javascriptimport { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';

const client = createPublicClient({
    chain: mainnet,
    transport: http('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/'),
});

const feeHistory = await client.getFeeHistory({
    blockCount: 5,
    rewardPercentiles: [25, 50, 75],
});
console.log('Base fees:', feeHistory.baseFeePerGas);
console.log('Reward percentiles:', feeHistory.reward);