klay_feeHistory

Returns base fee per gas and transaction effective priority fee per gas history for the requested block range if available.

NOTE: This API is effective after Klaytn v1.8.0

📘

Supported on Klaytn (mainnet) only.

Parameters

Request

NameTypeDescription
blockCountQUANTITYNumber of blocks in the requested range in hexadecimal. Between 1 (0x1) and 1024 (0x400) blocks can be requested in a single query. Less than requested may be returned if not all blocks are available.
lastBlockQUANTITY | TAGHighest numbered block of the requested range as block number or block tag.
rewardPercentilesArray of FLOATAn array of floating point values between 0 and 100.

Result

NameTypeDescription
oldestBlockQUANTITYLowest numbered block of the returned range in hexadecimal.
baseFeePerGasArray of QUANTITYAn 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.
gasUsedRatioArray of FLOATAn array of the ratios of gas used per block. These are calculated as the ratio of gasUsed and gasLimit.
rewardArray of QUANTITYAn array of effective priority fee per gas data points from a single block. All zeroes are returned if the block is empty.

API Endpoint

The format of a Klaytn API endpoint is
https://open-platform.nodereal.io/{{apiKey}}/klaytn/

Here is an example:
https://open-platform.nodereal.io/4c0a1c23661a4e26bcbcwed461e34ea9/klaytn/

Example

// Request
curl https://open-platform.nodereal.io/{{apiKey}}/klaytn/ \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"klay_feeHistory","params":["0x10", "latest", [0.1, 0.2, 0.3]],"id":1}' 

// Result
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "oldestBlock": "0xa5b",
    "reward": [
      [ "0x0", "0x0", "0x0" ],
      ...
      [ "0x5d21dba00", "0x5d21dba00", "0x5d21dba00" ]
    ],
    "baseFeePerGas": [ "0x0", ..., "0x0" ],
    "gasUsedRatio": [ 0, ..., 0.0002963777000002964 ]
  }
}