getFeeHistory
Returns a collection of historical gas information.
Usage
example.ts
import { publicClient } from './client'
 
const feeHistory = await publicClient.getFeeHistory({ 
  blockCount: 4,
  rewardPercentiles: [25, 75]
})Returns
The fee history.
Parameters
blockCount
- Type: number
Number of blocks in the requested range. Between 1 and 1024 blocks can be requested in a single query. Less than requested may be returned if not all blocks are available.
const feeHistory = await publicClient.getFeeHistory({
  blockCount: 4, 
  rewardPercentiles: [25, 75]
})rewardPercentiles
- Type: number[]
A monotonically increasing list of percentile values to sample from each block's effective priority fees per gas in ascending order, weighted by gas used.
const feeHistory = await publicClient.getFeeHistory({
  blockCount: 4,
  rewardPercentiles: [25, 75] 
})blockNumber (optional)
- Type: number
Highest number block of the requested range.
const feeHistory = await publicClient.getFeeHistory({
  blockCount: 4,
  blockNumber: 1551231n, 
  rewardPercentiles: [25, 75]
})blockTag (optional)
- Type: 'latest' | 'earliest' | 'pending' | 'safe' | 'finalized'
- Default: 'latest'
Highest number block of the requested range.
const feeHistory = await publicClient.getFeeHistory({
  blockCount: 4,
  blockTag: 'safe', 
  rewardPercentiles: [25, 75]
})JSON-RPC Method
- Calls eth_feeHistory.

