eth_feeHistory
Returns transaction base fee and effective priority fee history for the requested block range on Avalanche C-Chain.
Parameters
QUANTITY
- Number of blocks in the requested range. Between 1 and 1024 blocks can be requested in a single query.QUANTITY|TAG
- Highest number block of the requested range, or the string "latest"Array
- (optional) A monotonically increasing list of percentile values to sample from each block's effective priority fees per gas in ascending order, weighted by gas used.
{
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": [
"0x4",
"latest",
[25, 75]
],
"id": 1
}
Returns
Object
- Fee history for the returned block range which can be a subsection of the requested range if not all blocks are available:
oldestBlock
:QUANTITY
- Lowest number block of returned range.baseFeePerGas
:Array
- Array of block base fees per gas.gasUsedRatio
:Array
- Array of block gas used ratios.reward
:Array
- Array of effective priority fee per gas data points from a single block.
Implementation Example
- cURL
- JavaScript
curl -X POST https://api-avalanche-mainnet-archive.n.dwellir.com/YOUR_API_KEY/ext/bc/C/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": [
"0x4",
"latest",
[25, 75]
],
"id": 1
}'
const response = await fetch('https://api-avalanche-mainnet-archive.n.dwellir.com/YOUR_API_KEY/ext/bc/C/rpc', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_feeHistory',
params: [
'0x4',
'latest',
[25, 75]
],
id: 1
})
});
const data = await response.json();
console.log(data.result);
Response Example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"oldestBlock": "0x10d4f",
"baseFeePerGas": [
"0x7",
"0x7",
"0x7",
"0x7",
"0x7"
],
"gasUsedRatio": [
0.026089875,
0.406803,
0.0,
0.0
],
"reward": [
[
"0x77359400",
"0x77359400"
],
[
"0x0",
"0x0"
],
[
"0x0",
"0x0"
],
[
"0x0",
"0x0"
]
]
}
}
Note: Use this method to analyze fee trends on Avalanche C-Chain for optimal transaction pricing with EIP-1559.
Need help? Contact our support team or check the Avalanche documentation.