3

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.

2 Answers 2

2

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

1

As described in the about, the Gas Station monitors a single node and claims to track every block. However, it is not always giving accurate results even if it is doing that. When the network is busy, too many transactions seem to be getting re-broadcast and potentially appear to be pending for far less time than is actually the case.

Looking at a small number of individual transactions from example the etherscan pending transactions suggests that without monitoring a large proportion of transactions (maybe aggregated across several nodes), it is hard to determine reliable gas prices.

Your Answer

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

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