eth_feeHistory
Returns base fee per gas and gas used ratio for recent blocks.
Parameters
See Ethereum JSON-RPC spec for parameters of eth_feeHistory
.
Examples
- cURL
- Ethers.js v6
- Viem
- Python (web3.py)
curl -s -X POST https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_feeHistory","params":[],"id":1}'
import { JsonRpcProvider } from 'ethers';
const provider = new JsonRpcProvider('https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY');
const res = await provider.send('eth_feeHistory', []);
console.log(res);
import { createPublicClient, http } from 'viem';
const client = createPublicClient({ transport: http('https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY') });
const res = await client.request({ method: 'eth_feeHistory', params: [] });
console.log(res);
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY'))
res = w3.provider.make_request('eth_feeHistory', [])
print(res)
Response
- Success: JSON object with result
- Error: JSON object with error
{"code": <number>, "message": <string>}