[Ethereum] How to get Safe Low, Standard and Fast gas prices

gas-pricesolidity

I was relying on web3.eth.gasPrice() to get the safe gas price for my transactions, but unfortunately this doesn't give accurate results (check eth.gasPrice is returning less value than expected).

But I can see eth-gas-station returns values that we can rely on. I had also looked at blockcypher-apis for the same. They give us values in safe Low, Standard and Fast gas prices, and hence we have a better idea of what gas price should be suitable for our transaction.

Now my question is there any better way of getting this data, apart from using 3rd party api's. As I can figure out, the possible way seems to watch previous blocks and probably take the average of past few blocks. But I am not pretty sure if this is a good idea. And even in this case, I am not sure how to get low, standard and fast gas prices.

How does eth-gas-station and other channels providing such info get this data. Is there any option apart from crawling every block.

Best Answer

you can try this api to get the real-time prices https://www.etherchain.org/api/gasPriceOracle

Related Topic