eth_feeHistory
Returns historical gas information for the Unichain network. This method is useful for gas price estimation and understanding network congestion patterns over time.
Parameters​
QUANTITY
- Number of blocks to retrieve. Must be between 1 and 1024.QUANTITY|TAG
- Highest block number to retrieve from (or "latest", "earliest", "pending").Array
- Array of percentile values (0-100) to retrieve priority fees for.
Returns​
Object
containing:
oldestBlock
:QUANTITY
- Lowest block number returnedbaseFeePerGas
:Array
- Array of base fees per gas for each blockgasUsedRatio
:Array
- Array of gas used ratios for each block (0.0 to 1.0)reward
:Array
- Array of arrays containing priority fees at requested percentiles
Implementation Example​
- cURL
- JavaScript
curl -X POST https://api-unichain-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": ["0x4", "latest", [25, 50, 75]],
"id": 1
}'
const response = await fetch('https://api-unichain-mainnet.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_feeHistory',
params: ['0x4', 'latest', [25, 50, 75]],
id: 1
})
});
const data = await response.json();
console.log(data.result);
Response Example​
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"oldestBlock": "0x1a2b3c4",
"baseFeePerGas": [
"0x3b9aca00",
"0x3b9aca00",
"0x3b9aca00",
"0x3b9aca00"
],
"gasUsedRatio": [0.5, 0.6, 0.4, 0.7],
"reward": [
["0x77359400", "0x77359400", "0x77359400"],
["0x77359400", "0x77359400", "0x77359400"],
["0x77359400", "0x77359400", "0x77359400"]
]
}
}
This example shows fee history for 4 blocks with priority fee percentiles at 25%, 50%, and 75%.
Need help? Contact our support team or check the Unichain documentation.