[Ethereum] How to get the actual Gas price

gas-price

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.

Best Answer

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.