16

Is there a way to get the lowest and average price miners are asking for gas? Some statistics sites seem to have prices but they are outdated.

5 Answers 5

13

EDIT: with EIP-1559 (shipped in London fork in July 2021) this is not true anymore. I'm changing this answer to community wiki so that anyone can fix it (I don't really have time, sorry)


As explained in the Ethereum github's wiki the gas price is set by miners and the only way to guess the acceptable value is to look at the last block gas price. Then you look at the lowest and highest prices on the block and next block price should fit close to these values. Looking at more blocks in the past could give you a trend to guess if the price raises or goes down. But there is also a part of random, at least in Geth, so you can't exactly predict the gas price but only be close to the future block price. I think you can't be more accurate than geth gas price oracle.

2
  • Nice @nicolas, it your answer gave me insight. Still wondering if you know how Mist does it, they are not using the oracle, are they? Commented Jul 4, 2016 at 18:43
  • I didn't have time to look at mist code for the moment... sorry. Commented Jul 4, 2016 at 18:52
13

web3 has an async function called getGasPrice. In a geth terminal I can use:

web3.eth.getGasPrice(function(e, r) { console.log(r) })

This currently returns 20000000000 in geth on mainnet (20 Shannon). I imagine it is using the price used in the last block that was mined.

Note: The price specified by the sender is the highest price they're willing to pay. The minor will choose whether or not to process the transaction at their own discretion.

1
  • Still relevant in 2023. It has been checked on a private self-hosted network.
    – Gleichmut
    Commented Apr 17, 2023 at 16:32
4

It's been 3 years since this question has been posted and we now have 2 public APIs that determine the optimal gas price for a new Ethereum transaction:

Note that Etherchain piggybacks off EthGasStation, but their json response is less verbose, hence why I included it.

You may also want to read Gas Price Recommendations.

Update Jul 2021: Etherchain has stopped accepting requests from any domain, possibly because they are not using CORS in their API implementation. You will encounter errors when trying to fetch the gas price using their API, unless you become part of their allowlist (I don't know how to do this).

2

https://ethstats.net provides an idea about the current gas price and the gas limit in real time.

enter image description here

1
  • Site is dead...
    – a20
    Commented Apr 28, 2023 at 19:07
0

DefiSaver's Chrome plugin is quite nice and handy.

enter image description here

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Apr 29, 2023 at 3:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.