Gas Price Estimation – How to Estimate Using Ethers.js

ethers.jsgasgas-estimate

I'm looking to estimate transaction fees in an application. In order to do so I need to estimate the current gas price before I execute the transaction.

I see web3.js has a getGasPrice method:
https://web3js.readthedocs.io/en/v1.3.4/web3-eth.html#getgasprice

Is there a similar method in ethers.js? Or what is the recommended approach here?

Best Answer

Found it! https://docs.ethers.io/v5/api/providers/provider/#Provider-getGasPrice

Hint: the search functionality on docs.ethers.io isn't great - this method didn't show up by searching for "gasprice": https://docs.ethers.io/v5/search/?search=gasprice

Related Topic