Ethereum

Ethereum

eth_gasPrice

eth_gasPrice gives you the node's single suggested price per unit of gas, in wei of ETH, for Ethereum mainnet. It predates EIP-1559: on London-and-later Ethereum the node derives this figure from the current base fee plus a typical tip and collapses it into one number, the way a legacy type-0 transaction expects. It's a fast, no-parameter read of "what's gas roughly costing right now." Hit https://ethereum.therpc.io/YOUR_API_KEY (chain ID 1) and you get back something like 0x4a817c800 — 20 gwei. For modern type-2 transactions you'll usually want the richer eth_feeHistory data instead, but this remains the quickest pulse-check.

Use cases

  • Quick fee pulse. One CU, no params — a fast read to see whether Ethereum gas is sitting at a few gwei or spiking into the hundreds before you decide to transact.
  • Legacy transactions. Fill the gasPrice field on a type-0 transaction for tooling or hardware wallets that still build pre-1559 transactions.
  • One input to a fee oracle. Blend this single value with eth_feeHistory percentiles to cross-check your estimator rather than trusting either source alone.

Parameters

This method takes no parameters. Pass an empty array [].

Response

TypeDescription
string (hex)Hex-encoded gas price in wei (e.g. "0x4a817c800" = 20 gwei).

Example request

curl https://ethereum.therpc.io/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": [],
"id": 1
}'

Try it live in the Ethereum playground.

Errors & troubleshooting

CodeMessageCause
-32603Internal errorNode could not estimate current gas price.

Common pitfalls

  • On post-London Ethereum this is a synthesized number (base fee plus an assumed tip) and tends to run high. For a type-2 transaction you'll overpay if you copy it into maxFeePerGas; reach for eth_maxPriorityFeePerGas and eth_feeHistory instead.
  • The value is wei. To show "20 gwei" divide by 1e9; to show an ETH cost divide by 1e18. Skipping the conversion and printing the raw wei integer is a common UI bug.

Supported networks

  • Mainnet — Chain ID: 1
  • Sepolia — Chain ID: 11155111

See also

curl https://ethereum.therpc.io/YOUR_API_KEY \
-X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"eth_gasPrice","params":[]}'

Ready to call this in production?

Free tier covers personal projects. Pay-as-you-go scales without a card.