[Ethereum] ethers.js – estimating gas limit

ethers.jsgas-estimategas-limit

Using the ethers.js library, how can I determine the gas limit when sending a transaction to a contract or deploying a new contract?

Best Answer

From the official documentation, see the deployment section from contracts module. The section provides an example of deploying a contract on ropsten. From the contract deployment hash, you can get the idea of different gas parameters:

Transaction Fee: 0.00181826 Ether ($0.000000)

Gas Limit: 363,652

Gas Used by Transaction: 363,652 (100%)

Gas Price: 0.000000005 Ether (5 Gwei)

You can read more about gas estimation from this issue and this issue.

hope it will help.

Related Topic