8

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.

6

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.

  • 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? – Roland Kofler Jul 4 '16 at 18:43
  • I didn't have time to look at mist code for the moment... sorry. – Nicolas Massart Jul 4 '16 at 18:52
4

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.

2

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

enter image description here

0

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

Not 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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