eth_feeHistory
Returns base fee per gas and transaction effective priority fee per gas history for the requested block range if available. The range between headBlock-4 and headBlock is guaranteed to be available while retrieving data from the pending block and older history are optional to support. For pre-EIP-1559 blocks, the gas prices are returned as rewards and zeroes are returned for the base fee per gas.
blockCount and newestBlock are both required parameters

REQUEST

1
curl -X POST --data '{ "id": 1337, "jsonrpc": "2.0", "method": "eth_feeHistory", "params": ["0x5", "latest", []] }' https://mainnet.infura.io/v3/YOUR-PROJECT-ID
Copied!
1
Content-Type: application/json
Copied!

EXAMPLE

1
## JSON-RPC over HTTPS POST
2
## Replace YOUR-PROJECT-ID with a Project ID from your Infura Dashboard
3
## You can also replace mainnet with a different supported network
4
curl https://mainnet.infura.io/v3/YOUR-PROJECT-ID \
5
-X POST \
6
-H "Content-Type: application/json" \
7
-d '{"id": 1, "jsonrpc": "2.0", "method": "eth_feeHistory", "params": ["0x5", "latest", []] }'
8
9
## JSON-RPC over WSS
10
## Replace YOUR-PROJECT-ID with a Project ID from your Infura Dashboard
11
## You can also replace mainnet with a different supported network
12
wscat -c wss://mainnet.infura.io/ws/v3/YOUR-PROJECT-ID
13
>{"jsonrpc":"2.0","method":"eth_feeHistory","params":["0x5", "latest", []],"id":1}
Copied!

RESPONSE

RESULT FIELDS

  • oldestBlock - Lowest number block of the returned range expressed as a hexidecimal number.
  • 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 - An array of effective priority fee per gas data points from a single block. All zeroes are returned if the block is empty.

BODY

1
{
2
"jsonrpc": "2.0",
3
"id": 1,
4
"result": {
5
"baseFeePerGas": [
6
"0x92db30f56",
7
"0x9a47da3c5",
8
"0x8fb856b5b",
9
"0xa1a3c78d9",
10
"0x91a6775ac",
11
"0x7f71a86f7"
12
],
13
"gasUsedRatio": [
14
0.7022238670892842,
15
0.2261976964422899,
16
0.9987387,
17
0.10431753273738473,
18
0
19
],
20
"oldestBlock": "0xC72641"
21
}
22
}
Copied!
Copy link