Skip to content

eth_feeHistory

Returns a collection of historical gas information from which you can recompute gas costs.

Parameters

  1. string - Number of blocks in the requested range (in hexadecimal)
  2. string - Highest block number in the requested range (in hexadecimal) or "latest"
  3. array - Percentile values to sample from each block's effective priority fees

Example

["0x5", "latest", [20, 70]]

Returns

object

Returns an object with fee history data:

interface FeeHistory {
  oldestBlock: string; // Lowest block number in the range
  baseFeePerGas: Array<string>; // Array of block base fees per gas
  gasUsedRatio: Array<number>; // Array of block gas utilization ratios
  reward?: Array<Array<string>>; // Array of effective priority fee per gas data points for each block
}

Example

{
  "oldestBlock": "0x1",
  "baseFeePerGas": [
    "0x3b9aca00",
    "0x3ba1f3e2",
    "0x3a6db1e6"
  ],
  "gasUsedRatio": [
    0.5265,
    0.4858,
    0.6124
  ],
  "reward": [
    [
      "0x3b9aca00",
      "0x3b9aca00"
    ],
    [
      "0x3ba1f3e2",
      "0x3b9aca00"
    ],
    [
      "0x3a6db1e6",
      "0x3b9aca00"
    ]
  ]
}

Errors

CodeMessage
-32602Invalid parameters