Skip to main content
Monad API method that returns the current gas price in wei. This value is determined by the network and represents the median gas price of recent blocks.
Get you 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

  • none

Response

  • result — the current gas price in wei, encoded as hexadecimal.

eth_gasPrice code examples

const { ethers } = require("ethers");

const provider = new ethers.JsonRpcProvider("CHAINSTACK_NODE_URL");

async function getGasPrice() {
  const feeData = await provider.getFeeData();
  console.log(`Gas price: ${ethers.formatUnits(feeData.gasPrice, "gwei")} gwei`);
}

getGasPrice();

Use case

A practical use case for eth_gasPrice is calculating transaction costs before sending transactions, allowing users to see estimated fees in their wallet or DApp interface.