Updated on 2023-12-06 GMT+08:00

eth_feeHistory

Introduction

This API returns historical gas information. It consumes 32 CUs.

Parameter Description

Parameter

Type

Description

Number of blocks

String/Integer

Number of blocks in the requested range. 1 to 1024 blocks can be requested in a single query. Less than requested may be returned if not all blocks are available.

Newest block number

String

A hexadecimal block number, or the string (earliest, latest, or pending).

Reward percentiles

Integer

(Optional) 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.

Return Value

  • oldestBlock: the lowest number block of the returned range encoded as hexadecimal.
  • baseFeePerGas: an array of block base fees per gas, including an extra block value. The extra value is the next block after the newest block in the returned range. Zeroes are returned for blocks created before EIP-1559.
  • gasUsedRatio: an array of block gas used ratios. These are calculated as the ratio of gasUsed and gasLimit.
  • reward: an array of effective priority fees per gas data points from a single block. All zeroes are returned if the block is empty.

Request

curl https://your-http-endpoint/v1/<API-KEY> \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"id": 1, "jsonrpc": "2.0", "method": "eth_feeHistory", "params": ["0x5", "latest", [20,30]] }'