eth_gasPrice
https://api.triport.io/v1/polygonReturns the node's current legacy gas-price suggestion, in wei, as a hex string.
eth_gasPrice returns the node's current best estimate of the gas price on
Polygon mainnet (chain ID 0x89 / 137), encoded as a 0x-prefixed hexadecimal
string in wei. It takes no parameters. The value represents what the node
considers a competitive price for a legacy (pre-EIP-1559) transaction.
Use it when you need a single, simple gas-price figure — for example, when
constructing a legacy type: 0x0 transaction that carries a flat gasPrice
field, or for a quick fee-level readout in a dashboard.
Prefer EIP-1559 fee methods on Polygon. Since the Bhilai hardfork, Polygon
uses the EIP-1559 fee market (a per-block baseFeePerGas plus a priority tip),
so a single gasPrice value is a coarse fallback. For accurate fee estimation
on EIP-1559 transactions (maxFeePerGas / maxPriorityFeePerGas), use
eth_maxPriorityFeePerGas or
eth_feeHistory and add a tip. eth_gasPrice remains
useful for legacy transactions and for rough, human-readable estimates. Note
that Polygon gas prices typically sit well above Ethereum's — values around
30 gwei are common.
Parameters
This method takes no parameters; pass an empty array.
_(none)_arrayrequired[].Response
Response fields
| Field | Type | Description |
|---|---|---|
jsonrpc | string | JSON-RPC version, always "2.0". |
id | number | Echoes the request id. |
result | string | Current gas-price estimate in wei as a 0x-prefixed hex string (e.g. 0x6fc23ac00 = 30000000000 wei = 30 gwei). |
Errors
| Code | Meaning | When it happens |
|---|---|---|
-32001 | trial_expired | The account's trial period has ended; upgrade to a paid tier to continue. |
-32002 | tier_insufficient | The current tier may not call this method. (eth_gasPrice is available from the free tier, so this is rare here.) |
-32003 | rate_limited | The per-tier RPS limit was exceeded. Back off and retry after data.retry_after_sec. |
-32004 | subscription_expired | The account's subscription has lapsed. |
-32005 | unauthorized | The API key is missing, malformed, or invalid. |
-32601 | method_unknown | The method name is not recognized on this chain. |
See errors.md for the full error envelope and handling guidance.
Examples
JavaScript (fetch)
const res = await fetch("https://api.triport.io/v1/polygon", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "eth_gasPrice",
params: [],
}),
});
const { result } = await res.json();
const wei = BigInt(result);
console.log("gas price:", Number(wei) / 1e9, "gwei"); // 30 gweiTypeScript SDK (@triport/sdk)
import { Triport } from "@triport/sdk";
const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });
const result = await client.polygon.request<string>("eth_gasPrice", []);
console.log("gas price (gwei):", Number(BigInt(result)) / 1e9);Python (triport-sdk)
import os
from triport import Triport
client = Triport(api_key=os.environ["TRIPORT_API_KEY"])
result = client.polygon.request("eth_gasPrice", [])
print("gas price (gwei):", int(result, 16) / 1e9)Notes
- The result is a hex string in wei, not a number — convert with base 16
(or
BigInt) before arithmetic, and divide by1e9to get gwei. eth_gasPriceis available on the free tier (polygon_read_rpccategory).- Rate limiting is RPS-per-tier with burst; there is no daily quota. A
-32003 rate_limitederror means you should back off and retry shortly. - This is a legacy method on a post-Bhilai EIP-1559 chain. For accurate fee
estimation use
eth_maxPriorityFeePerGasoreth_feeHistory; to read the latest chain head, seeeth_blockNumber.