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

Parameter
Type
Required
Description

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
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]]
}'

Response Example

response.json
{
  "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

Parameter
Type
Description

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

Error Code
Description

-32602

Invalid params - invalid block count or range

-32603

Internal error - node processing issues

SDK Integration

Last updated

Was this helpful?