eth_feeHistory
Returns fee history for a range of blocks.
Parameters
See Ethereum JSON-RPC spec for parameters of eth_feeHistory
.
Examples
- cURL
- Ethers.js v6
- Viem
- web3.py
curl -X POST https://api-chiliz-mainnet-archive.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": [
"0x10",
"latest",
[25, 50, 75]
],
"id": 1
}'
import { JsonRpcProvider } from 'ethers';
const provider = new JsonRpcProvider(
'https://api-chiliz-mainnet-archive.n.dwellir.com/YOUR_API_KEY'
);
// Get fee history
const feeHistory = await provider.send('eth_feeHistory', [
'0x10', // 16 blocks
'latest',
[25, 50, 75] // 25th, 50th, 75th percentiles
]);
console.log('Fee history:', feeHistory);
import { createPublicClient, http, defineChain } from 'viem';
const chiliz = defineChain({
id: 88888,
name: 'Chiliz',
nativeCurrency: {
decimals: 18,
name: 'CHZ',
symbol: 'CHZ',
},
rpcUrls: {
default: {
http: ['https://api-chiliz-mainnet-archive.n.dwellir.com/YOUR_API_KEY'],
},
},
blockExplorers: {
default: { name: 'ChilizScan', url: 'https://chiliscan.com' },
},
});
const client = createPublicClient({
chain: chiliz,
transport: http('https://api-chiliz-mainnet-archive.n.dwellir.com/YOUR_API_KEY'),
});
// Get fee history
const feeHistory = await client.getFeeHistory({
blockCount: 16,
rewardPercentiles: [25, 50, 75],
});
console.log('Fee history:', feeHistory);
from web3 import Web3
w3 = Web3(Web3.HTTPProvider(
'https://api-chiliz-mainnet-archive.n.dwellir.com/YOUR_API_KEY'
))
# Get fee history
fee_history = w3.eth.fee_history(
block_count=16,
newest_block='latest',
reward_percentiles=[25, 50, 75]
)
print(f"Fee history: {fee_history}")
Response
Returns fee history with base fee and priority fee percentiles. Common error responses:
{"code": -32700, "message": "Parse error"}
- Invalid JSON{"code": -32602, "message": "Invalid params"}
- Invalid parameters{"code": -32603, "message": "Internal error"}
- Server error