Skip to content

getFeeHistory

Returns a collection of historical gas information.

Usage

example.ts
import { publicClient } from "./client";

const feeHistory = await publicClient.getFeeHistory({
  epochCount: 4,
  rewardPercentiles: [25, 75],
});

Returns

FeeHistory

Parameters

epochCount (optional)

  • Type: number

the number of epochs to query.

const feeHistory = await publicClient.getFeeHistory({
  epochCount: 4, 
  rewardPercentiles: [25, 75],
});

rewardPercentiles (optional)

  • Type: number[]

A monotonically increasing float list of percentile values. For each block in the requested range, the transactions will be sorted in ascending order by effective tip per gas and the coresponding effective tip for the percentile will be determined, accounting for gas consumed.

const feeHistory = await publicClient.getFeeHistory({
  epochCount: 4,
  rewardPercentiles: [25, 75], 
});

epochNumber (optional)

  • Type: number The epoch number
const feeHistory = await publicClient.getFeeHistory({
  epochCount: 4,
  epochNumber: 1n, 
  rewardPercentiles: [25, 75],
});

epochTag (optional)

  • type: latest_state| latest_confirmed| latest_checkpoint |earliest
  • Defaut: latest_state The epoch tag
const feeHistory = await publicClient.getFeeHistory({
  epochCount: 4,
  epochTag: "latest_state", 
  rewardPercentiles: [25, 75],
});

JSON-RPC Method

cfx_feeHistory