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

  • Could you please elaborate on your use case? What are you building, what exactly is the commission for? – iamdefinitelyahuman Nov 9 '19 at 8:11
  • For sending, I use npm ethers module – Артем Филиппов Nov 9 '19 at 9:08
  • When you say commission, do you mean the fee paid to the miners? – iamdefinitelyahuman Nov 9 '19 at 9:10
  • For sending, I use npm ethers module. To send all funds , the formula for receiving the value field is used tx.value = balance - gasLimit * gasPrcie. But when the tx.data field is added, the transaction is not sent due to lack of funds – Артем Филиппов Nov 9 '19 at 9:16
  • Yes "commission" = transaction fee – Артем Филиппов Nov 9 '19 at 9:17

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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