eth_feeHistory - Somnia
Example code for the eth_feeHistory JSON-RPC method. Complete guide on how to use eth_feeHistory JSON-RPC in GetBlock Web3 documentation.
This method returns historical gas information on the Somnia network. This is useful for estimating appropriate gas prices based on recent network activity. Somnia's predictable gas pricing through IceDB makes this data particularly reliable.
Parameters
blockCount
string
Yes
Number of blocks to return (hex)
newestBlock
string
Yes
Highest block number, or "latest", "pending"
rewardPercentiles
array
No
Percentiles for priority fee sampling
Request Example
curl -X POST https://go.getblock.io/<ACCESS-TOKEN>/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "getblock.io",
"method": "eth_feeHistory",
"params": ["0x5", "latest", [25, 50, 75]]
}'const axios = require('axios');
const url = 'https://go.getblock.io/<ACCESS-TOKEN>/';
const payload = {
jsonrpc: '2.0',
id: 'getblock.io',
method: 'eth_feeHistory',
params: ['0x5', 'latest', [25, 50, 75]]
};
axios.post(url, payload, {
headers: { 'Content-Type': 'application/json' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));Response Example
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": {
"baseFeePerGas": ["0x3b9aca00", "0x3b9aca00", "0x3b9aca00", "0x3b9aca00", "0x3b9aca00", "0x3b9aca00"],
"gasUsedRatio": [0.5, 0.3, 0.4, 0.6, 0.2],
"oldestBlock": "0x1a2b38",
"reward": [
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"]
]
}
}Response Parameters
baseFeePerGas
array
Base fee for each block (n+1 entries)
gasUsedRatio
array
Gas utilization ratio (0.0 to 1.0)
oldestBlock
string
First block in the range
reward
array
Priority fee at each percentile
Use Cases
Implement dynamic gas pricing
Analyze network congestion patterns
Optimize transaction timing
Build gas estimation algorithms
Monitor network utilization
Error Handling
-32602
Invalid params - invalid block count or range
-32603
Internal error - node processing issues
SDK Integration
Last updated
Was this helpful?