eth_gasPrice
Returns the current price per gas in wei.
Parameters
Section titled “Parameters”None.
Returns
Section titled “Returns”QUANTITY — Integer of the current gas price in wei.
Request
Section titled “Request”curl -X POST https://eth-mainnet.blockreq.com/v1/rpc/public \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":1}'Response
Section titled “Response”{ "jsonrpc": "2.0", "id": 1, "result": "0x3b9aca00"}
0x3b9aca00= 1,000,000,000 wei = 1 Gwei
Code Examples
Section titled “Code Examples”JavaScript (ethers.js v6)
Section titled “JavaScript (ethers.js v6)”import { JsonRpcProvider, formatUnits } from "ethers";const provider = new JsonRpcProvider("https://eth-mainnet.blockreq.com/v1/rpc/YOUR_API_KEY");const feeData = await provider.getFeeData();console.log("Gas price:", formatUnits(feeData.gasPrice, "gwei"), "Gwei");Python (web3.py)
Section titled “Python (web3.py)”from web3 import Web3w3 = Web3(Web3.HTTPProvider("https://eth-mainnet.blockreq.com/v1/rpc/YOUR_API_KEY"))gas_price = w3.eth.gas_priceprint(f"Gas price: {w3.from_wei(gas_price, 'gwei')} Gwei")RU Cost
Section titled “RU Cost”| Method | Cost |
|---|---|
| eth_gasPrice | 5 RU |