Skip to main content
POST
eth_feeHistory
curl --request POST \
  --url https://rpc.testnet.tempo.xyz/ \
  --header 'Content-Type: application/json' \
  --data '
{
  "jsonrpc": "2.0",
  "method": "eth_feeHistory",
  "params": [
    4,
    "latest",
    [
      25,
      75
    ]
  ],
  "id": 1
}
'
{
  "jsonrpc": "<string>",
  "id": 123,
  "result": {
    "baseFeePerGas": [
      "<string>"
    ],
    "gasUsedRatio": [
      123
    ],
    "oldestBlock": "<string>",
    "reward": [
      [
        "<string>"
      ]
    ]
  }
}
Tempo API method that returns historical gas information for a range of blocks. This is useful for estimating appropriate gas fees based on recent network activity.

Parameters

  • blockCount — number of blocks to return (hex or integer, max 1024)
  • newestBlock — highest block number or tag (latest, pending)
  • rewardPercentiles — (optional) array of percentiles to calculate priority fees

Response

  • result — the fee history object:
    • baseFeePerGas — array of base fees for each block (plus next block)
    • gasUsedRatio — array of gas used ratios for each block
    • oldestBlock — the oldest block number in the range
    • reward — (optional) array of priority fee percentiles for each block

eth_feeHistory code examples

const ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);

const getFeeHistory = async () => {
    // Get fee history for last 10 blocks with 25th, 50th, 75th percentiles
    const feeHistory = await provider.send("eth_feeHistory", [
      "0xa",
      "latest",
      [25, 50, 75]
    ]);

    console.log(`Oldest block: ${parseInt(feeHistory.oldestBlock, 16)}`);
    console.log(`\nBase fees (gwei):`);

    for (let i = 0; i < feeHistory.baseFeePerGas.length; i++) {
      const baseFee = ethers.formatUnits(feeHistory.baseFeePerGas[i], "gwei");
      const gasRatio = feeHistory.gasUsedRatio[i] ? (feeHistory.gasUsedRatio[i] * 100).toFixed(2) : "N/A";
      console.log(`  Block +${i}: ${baseFee} gwei (${gasRatio}% full)`);
    }

    if (feeHistory.reward) {
      console.log(`\nPriority fee percentiles for latest block (gwei):`);
      const latest = feeHistory.reward[feeHistory.reward.length - 1];
      console.log(`  25th: ${ethers.formatUnits(latest[0], "gwei")}`);
      console.log(`  50th: ${ethers.formatUnits(latest[1], "gwei")}`);
      console.log(`  75th: ${ethers.formatUnits(latest[2], "gwei")}`);
    }
  };

getFeeHistory();

Body

application/json
jsonrpc
string
default:2.0
method
string
default:eth_feeHistory
params
any[]

Block count, newest block, and reward percentiles

id
integer
default:1

Response

200 - application/json

Fee history

jsonrpc
string
id
integer
result
object