eth_feeHistory - Base
Example code for the eth_feeHistory JSON-RPC method. Complete guide on how to use eth_feeHistory JSON-RPC in GetBlock Web3 documentation.
Parameters
Parameter
Type
Required
Description
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": ["0xa", "latest", [25, 50, 75]],
"id": "getblock.io"
}'const axios = require('axios');
const response = await axios.post('https://go.getblock.io/<ACCESS-TOKEN>/', {
jsonrpc: '2.0',
method: 'eth_feeHistory',
params: ['0xa', 'latest', [25, 50, 75]],
id: 'getblock.io'
}, {
headers: { 'Content-Type': 'application/json' }
});
const feeHistory = response.data.result;
console.log('Oldest Block:', parseInt(feeHistory.oldestBlock, 16));
console.log('Base Fees:', feeHistory.baseFeePerGas.map(f => parseInt(f, 16)));Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": {
"oldestBlock": "0x12d6876",
"baseFeePerGas": [
"0x5f5e100",
"0x5f5e100",
"0x5f5e100",
"0x5f5e100",
"0x5f5e100",
"0x5f5e100",
"0x5f5e100",
"0x5f5e100",
"0x5f5e100",
"0x5f5e100",
"0x5f5e100"
],
"gasUsedRatio": [
0.0,
0.1234,
0.0567,
0.0,
0.2345,
0.0,
0.0,
0.0891,
0.0,
0.0
],
"reward": [
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"]
]
}
}Response Parameters
Parameter
Type
Description
Use Cases
Error Handling
Error Code
Message
Description
Web3 Integration
Last updated
Was this helpful?