🟪 Polygon
eth_feeHistory

Polygon API Documentation


eth_feeHistory RPC Method

The eth_feeHistory returns the historical gas fee statistics for a given block range.

Parameters

  • blockCount - String or Integer - The number of blocks in the requested range. Between 1 and 1024 blocks can be requested in a single query. It will return less than the requested range if not all blocks are available.

  • newestBlock - String - The highest number block of the requested range or on og the Tags "latest", "earliest", "pending", "safe" or "finalized".

"Safe" and "finalized" are only availible on Ethereum and Arbitrum One chains. Read block parameter description (opens in a new tab).

  • rewardPercentiles [optional] - Integer - 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.

Returns

  • oldestBlock - The lowest number block of the returned range encoded in hexadecimal format.

  • baseFeePerGas - An array of block base fees per gas. This includes the next block after the newest of the returned range, because this value can be derived from the newest block. Zeroes are returned for pre-EIP-1559 blocks.

  • gasUsedRatio - An array of block gas used ratios. These are calculated as the ratio of gasUsed and gasLimit.

  • reward [optional] - An array of effective priority fees per gas data points from a single block. All zeroes are returned if the block is empty.

Request

POST https://<network>.chainnodes.org/YOUR-API-KEY

Example

💡 Confusing?

Ask our experienced blockchain developers in Telegram

  • HTTPS POST Request with a JSON RPC call in the body
  • Replace YOUR-API-KEY with the API key from your CHAINNODES.ORG Dashboard
  • You can use a different supported network by replacing polygon-mainnet
curl https://polygon-mainnet.chainnodes.org/YOUR-API-KEY \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_feeHistory","params": ["0x8", "earliest", [20,25]],"id":1}'

Body

{
   "jsonrpc": "2.0",
   "id": 1,
   "result": {
      "oldestBlock": "0x0",
      "reward": [
         [
            "0x0",
            "0x0"
         ]
      ],
      "baseFeePerGas": [
         "0x0",
         "0x0"
      ],
      "gasUsedRatio": [
         0
      ]
   }
}

Need RPC API keys?

Get 12.5M archival requests for free today.

Some use cases:

  1. Fee Estimation: Wallets and users can use this method to better estimate the gas price for their transactions. By looking at the recent history of fees, they can make an informed decision about how much gas to allocate to a transaction, which can help to ensure that the transaction is processed in a timely manner without overpaying.
  2. Historical Analysis: Researchers and data analysts can use this method to study the historical trends in transaction fees on the Polygon network. This can provide insights into network usage over time, the impact of different network upgrades, and the behavior of users in response to changes in transaction fees.
  3. DApp Optimization: Developers of decentralized applications can use this method to optimize the gas costs of their applications. By understanding the fee history, it is possible to identify times when network fees are typically lower and schedule non-urgent transactions for these times.

JSON-RPC API Documentation by CHAINNODES is based on Erigon node client. Contact us if you are interested in specific methods that are only available on geth, besu, Nethermind or reth