0

This question has been asked a hundred times before. But with the change from v5 to v6 of the ethers.js library it has become unclear again how to do it. How can I estimate the cost of a transaction like a function call or contract deployment with ethers.js v6?

1 Answer 1

3

I had to figure it out too, but it's quite simple:

Ethers v5: myContract.estimateGas.myFunction(param1, param2);

Ethers v6: myContract.myFunction.estimateGas(param1, param2);

Turns out that the function name and .estimateGas have switched places; .estimateGas is now part of the function.

Your Answer

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

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