eth_feeHistory
curl --request POST \
--url https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf/ \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": [
4,
"latest",
[
25,
75
]
],
"id": 1
}
'import requests
url = "https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf/"
payload = {
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": [4, "latest", [25, 75]],
"id": 1
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_feeHistory',
params: [4, 'latest', [25, 75]],
id: 1
})
};
fetch('https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'method' => 'eth_feeHistory',
'params' => [
4,
'latest',
[
25,
75
]
],
'id' => 1
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf/"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_feeHistory\",\n \"params\": [\n 4,\n \"latest\",\n [\n 25,\n 75\n ]\n ],\n \"id\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf/")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_feeHistory\",\n \"params\": [\n 4,\n \"latest\",\n [\n 25,\n 75\n ]\n ],\n \"id\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_feeHistory\",\n \"params\": [\n 4,\n \"latest\",\n [\n 25,\n 75\n ]\n ],\n \"id\": 1\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "<string>",
"id": 123,
"result": {
"baseFeePerGas": [
"<string>"
],
"gasUsedRatio": [
123
],
"oldestBlock": "<string>",
"reward": [
[
"<string>"
]
]
}
}Tempo node API
eth_feeHistory | Tempo
Tempo API method that returns historical gas information for a range of blocks. Reference for eth_feeHistory on Tempo via Chainstack.
POST
/
eth_feeHistory
curl --request POST \
--url https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf/ \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": [
4,
"latest",
[
25,
75
]
],
"id": 1
}
'import requests
url = "https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf/"
payload = {
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": [4, "latest", [25, 75]],
"id": 1
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_feeHistory',
params: [4, 'latest', [25, 75]],
id: 1
})
};
fetch('https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'method' => 'eth_feeHistory',
'params' => [
4,
'latest',
[
25,
75
]
],
'id' => 1
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf/"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_feeHistory\",\n \"params\": [\n 4,\n \"latest\",\n [\n 25,\n 75\n ]\n ],\n \"id\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf/")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_feeHistory\",\n \"params\": [\n 4,\n \"latest\",\n [\n 25,\n 75\n ]\n ],\n \"id\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_feeHistory\",\n \"params\": [\n 4,\n \"latest\",\n [\n 25,\n 75\n ]\n ],\n \"id\": 1\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "<string>",
"id": 123,
"result": {
"baseFeePerGas": [
"<string>"
],
"gasUsedRatio": [
123
],
"oldestBlock": "<string>",
"reward": [
[
"<string>"
]
]
}
}Tempo API method that returns historical gas information for a range of blocks. This is useful for estimating appropriate gas fees based on recent network activity.
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.
Parameters
blockCount— number of blocks to return (hex or integer, max 1024)newestBlock— highest block number or tag (latest,pending)rewardPercentiles— (optional) array of percentiles to calculate priority fees
Response
result— the fee history object:baseFeePerGas— array of base fees for each block (plus next block)gasUsedRatio— array of gas used ratios for each blockoldestBlock— the oldest block number in the rangereward— (optional) array of priority fee percentiles for each block
eth_feeHistory code examples
const ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);
const getFeeHistory = async () => {
// Get fee history for last 10 blocks with 25th, 50th, 75th percentiles
const feeHistory = await provider.send("eth_feeHistory", [
"0xa",
"latest",
[25, 50, 75]
]);
console.log(`Oldest block: ${parseInt(feeHistory.oldestBlock, 16)}`);
console.log(`\nBase fees (gwei):`);
for (let i = 0; i < feeHistory.baseFeePerGas.length; i++) {
const baseFee = ethers.formatUnits(feeHistory.baseFeePerGas[i], "gwei");
const gasRatio = feeHistory.gasUsedRatio[i] ? (feeHistory.gasUsedRatio[i] * 100).toFixed(2) : "N/A";
console.log(` Block +${i}: ${baseFee} gwei (${gasRatio}% full)`);
}
if (feeHistory.reward) {
console.log(`\nPriority fee percentiles for latest block (gwei):`);
const latest = feeHistory.reward[feeHistory.reward.length - 1];
console.log(` 25th: ${ethers.formatUnits(latest[0], "gwei")}`);
console.log(` 50th: ${ethers.formatUnits(latest[1], "gwei")}`);
console.log(` 75th: ${ethers.formatUnits(latest[2], "gwei")}`);
}
};
getFeeHistory();
from web3 import Web3
node_url = "CHAINSTACK_NODE_URL"
web3 = Web3(Web3.HTTPProvider(node_url))
# Get fee history for last 10 blocks
result = web3.provider.make_request("eth_feeHistory", [
"0xa",
"latest",
[25, 50, 75]
])
fee_history = result['result']
oldest = int(fee_history['oldestBlock'], 16)
print(f"Oldest block: {oldest}")
print("\nBase fees (gwei):")
for i, base_fee in enumerate(fee_history['baseFeePerGas']):
base_fee_gwei = web3.from_wei(int(base_fee, 16), 'gwei')
gas_ratio = fee_history['gasUsedRatio'][i] * 100 if i < len(fee_history['gasUsedRatio']) else 'N/A'
print(f" Block +{i}: {base_fee_gwei} gwei ({gas_ratio:.2f}% full)" if isinstance(gas_ratio, float) else f" Block +{i}: {base_fee_gwei} gwei")
if fee_history.get('reward'):
print("\nPriority fee percentiles for latest block (gwei):")
latest = fee_history['reward'][-1]
print(f" 25th: {web3.from_wei(int(latest[0], 16), 'gwei')}")
print(f" 50th: {web3.from_wei(int(latest[1], 16), 'gwei')}")
print(f" 75th: {web3.from_wei(int(latest[2], 16), 'gwei')}")
curl -X POST "CHAINSTACK_NODE_URL" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": ["0xa", "latest", [25, 50, 75]],
"id": 1
}'
Last modified on June 22, 2026
Was this page helpful?
⌘I