eth_feeHistory - Celo

This method returns historical gas information on the Celo network, enabling accurate fee estimation for EIP-1559 style transactions. Celo maintains extremely low fees, typically under $0.01 per transaction.

Parameters

ParameterTypeRequiredDescription
blockCountstringYesNumber of blocks to return (hex)
newestBlockstringYesNewest block ("latest" or block number)
rewardPercentilesarrayNoPercentile values for priority fees

Request Example

bashcurl -X POST https://shared.eu-central-1.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]]
}'
javascriptconst axios = require('axios');

const url = 'https://shared.eu-central-1.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));
pythonimport requests
import json

url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"

payload = {
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "method": "eth_feeHistory",
    "params": ["0x5", "latest", [25, 50, 75]]
}

response = requests.post(url, headers={"Content-Type": "application/json"}, json=payload)
print(response.json())

Response Example

json{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "result": {
    "baseFeePerGas": ["0x5d21dba00", "0x5d21dba00", "0x5d21dba00"],
    "gasUsedRatio": [0.021, 0.045, 0.032],
    "oldestBlock": "0x1d9f2a4",
    "reward": [["0x0", "0x0", "0x0"], ["0x0", "0x0", "0x0"]]
  }
}

Reponse Definition

FieldTypeDescription
baseFeePerGasarrayBase fee per gas for each block
gasUsedRatioarrayGas used ratio for each block
oldestBlockstringOldest block number returned
rewardarrayPriority fee percentiles

Use Cases

  • Calculate optimal gas prices
  • Implement EIP-1559 fee estimation
  • Analyze network congestion
  • Build fee prediction models

Error Handling

Error CodeDescription
-32602Invalid params
-32603Internal error

SDK Integration

javascriptconst { ethers } = require('ethers');

const provider = new ethers.JsonRpcProvider('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');

const feeData = await provider.getFeeData();
console.log('Max Fee:', ethers.formatGwei(feeData.maxFeePerGas));
console.log('Priority Fee:', ethers.formatGwei(feeData.maxPriorityFeePerGas));