0

https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend

In the docs, contract.METHOD_NAME( ...args [ , overrides ] ) takes overrides for gasLimit and gasPrice

Is gasLimit the result of:

var gasLimit = await MyContract.estimateGas.myMethod('my argument', {value: 0.00056*10e18 })

which in this case returns 50584. The amount of Gas (in wei?) that myMethod() would need. Or is it 50584 * current_gas_price?

2 Answers 2

0

It would return the gas Limit. It would not multiply the gas limit by gas price. Hence the returned value in your case would be 50584, and NOT 50584 * current_gas_price.

1
  • I think OP wants to know if the gas that the call will consume is the gas limit or the gas limit times the gas price. Jul 17, 2023 at 8:35
0

If you make the same call twice under the same circumstances, both calls will consume the same amount of gas (the estimated 50584 that you mentioned). Gas is not to be confused with Wei. To calculate how much Wei you're going to pay for that call, you have to multiply the amount of gas used by the current gas price. That's why one time the same call may cost you more than another time, even if the amount of gas is exactly the same. Because the gas price may be different.

Compare it with driving from New York to LA in your car. You can estimate the amount of gas that it will need (50584). To know how much Wei you're going to pay for that, you have to multiply it by the gas price.

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.