curl --request POST \
--url https://monad-testnet.core.chainstack.com/9c5b265f20b3ea5df4f54f70eb74b800/ \
--header 'Content-Type: application/json' \
--data '
{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": [
"0x4",
"latest",
[
25,
75
]
]
}
'{
"jsonrpc": "<string>",
"id": 123,
"result": {}
}curl --request POST \
--url https://monad-testnet.core.chainstack.com/9c5b265f20b3ea5df4f54f70eb74b800/ \
--header 'Content-Type: application/json' \
--data '
{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": [
"0x4",
"latest",
[
25,
75
]
]
}
'{
"jsonrpc": "<string>",
"id": 123,
"result": {}
}blockCount — the number of blocks in the requested range (1 to 1024).newestBlock — the highest block of the requested range as a hexadecimal string or block tag.rewardPercentiles — an array of floating point values between 0 and 100 to sample the effective priority fees.result — an object containing:
oldestBlock — the oldest block in the rangebaseFeePerGas — array of base fees per gas for each blockgasUsedRatio — array of gas used ratios for each blockreward — array of arrays containing the requested percentile values of effective priority feeseth_feeHistory code examplesconst { ethers } = require("ethers");
const provider = new ethers.JsonRpcProvider("CHAINSTACK_NODE_URL");
async function getFeeHistory() {
const feeHistory = await provider.send("eth_feeHistory", ["0x4", "latest", [25, 50, 75]]);
console.log(`Oldest block: ${parseInt(feeHistory.oldestBlock, 16)}`);
console.log("Base fees:", feeHistory.baseFeePerGas.map(fee => ethers.formatUnits(fee, "gwei") + " gwei"));
console.log("Gas used ratios:", feeHistory.gasUsedRatio);
}
getFeeHistory();
eth_feeHistory is building a gas price oracle that analyzes historical trends to predict optimal gas prices, or creating dashboards that visualize network congestion over time.Was this page helpful?