eth_feehistory

Xinfin RPC

How to use it

// yarn add @tatumio/tatum

import { TatumSDK, Xinfin, Network } from '@tatumio/tatum'
  
const tatum = await TatumSDK.init<Xinfin>({ network: Network.XINFIN })

const feeHistory = await tatum.rpc.FeeHistory({ 
  blockCount: '1234',
  newestBlock: "latest",
  rewardPercentiles: [10, 20, 30],
})

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs

Overview

The eth_feeHistory retrieves historical gas fee data, providing insights into gas price trends and block utilization over time. This method is valuable for estimating transaction fees and understanding network congestion.

Parameters

The eth_feeHistory method accepts two parameters:

  1. blockCount(number): The number of blocks to include in the history.
    • Example: "1024"
  2. newestBlock(string): The block number at which you want to retrieve the contract code. This can be specified as a hex string or one of the following special keywords:
    • "earliest": The first block in the blockchain
    • "latest": The most recent block in the blockchain
    • "pending": The upcoming block that is being mined
      • Example: "0x1" or "latest"
  3. rewardPercentiles(number[]): An array of percentiles to calculate effective priority fees over the requested blocks.
    • Example: [50, 75, 90, 95, 99]

Return Object

The response from the eth_feeHistory method will be a JSON object containing the result, which is the historical gas fee data for the specified blocks. This data includes the base fee per gas, gas used ratio, and priority fees at the specified percentiles.

JSON Examples

Request

{
   "id": 1,
   "jsonrpc": "2.0",
   "method": "eth_feeHistory",
   "params":[
      1024,
      "latest",
      [
         10,
         20,
         30
      ]
   ]
}

Response

{
   "jsonrpc": "2.0",
   "id": 1,
   "result": {
      "oldestBlock": "0x158f303",
      "reward": [
         [
            "0xeaaee",
            "0xef7f1",
            "0xf3400"
         ]
      ],
      "baseFeePerGas": [ "0x7cf7d1"],
      "gasUsedRatio": [0.18955230555555555]
   }
}