TriportRPC

eth_gasPrice

POSThttps://api.triport.io/v1/ethereum

Returns the node's current estimate of the gas price, in wei, as a hex string.

Ethereumeth_read_rpcfree 10 RPS · basic 20 RPS · pro 100 RPS · business 250 RPS

eth_gasPrice returns the node's current best estimate of the gas price, encoded as a 0x-prefixed hexadecimal string in wei. It takes no parameters. The value is derived from recent block activity and 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 eth_feeHistory on EIP-1559 chains. Ethereum mainnet uses the EIP-1559 fee market (a per-block baseFeePerGas plus a priority tip), so a single gasPrice value is a coarse approximation. For accurate fee estimation on EIP-1559 transactions (maxFeePerGas / maxPriorityFeePerGas), use eth_feeHistory and add a tip. eth_gasPrice remains useful for legacy transactions and for rough, human-readable estimates.

Parameters

This method takes no parameters; pass an empty array.

_(none)_arrayrequired
Must be [].

Response

Response fields

FieldTypeDescription
jsonrpcstringJSON-RPC version, always "2.0".
idnumberEchoes the request id.
resultstringCurrent gas-price estimate in wei as a 0x-prefixed hex string (e.g. 0x3b9aca00 = 1000000000 wei = 1 gwei).

Errors

CodeMeaningWhen it happens
-32001trial_expiredThe account's trial period has ended; upgrade to a paid tier to continue.
-32003rate_limitedThe per-tier RPS limit was exceeded. Back off and retry.

See errors.md for the full error envelope and handling guidance.

Examples

JavaScript (fetch)

const res = await fetch("https://api.triport.io/v1/ethereum", {
  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"); // 1 gwei

TypeScript SDK (@triport/sdk)

import { Triport } from "@triport/sdk";


const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });


const result = await client.ethereum.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.ethereum.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 by 1e9 to get gwei.
  • eth_gasPrice is available on the free tier (eth_read_rpc category).
  • Rate limiting is RPS-per-tier with burst; there is no daily quota. A -32003 rate_limited error means you should back off and retry shortly.
  • This is a legacy method. For EIP-1559 fee estimation use eth_feeHistory; to read the latest chain head, see eth_blockNumber.