0

Why can I deploy contract on REMIX even if I set the gas limit to be 0?

I am a beginner to blockchain and Ethereum but I think deploying a contract on a blockchain also takes gas, then how is it possible if my gas limit is 0? enter image description here

2
  • Can you share the screenshot where you are setting it to zero? Commented Jun 26, 2023 at 16:48
  • @ZartajAfser added.
    – Y.T.
    Commented Jun 27, 2023 at 2:41

2 Answers 2

1

Indeed, deploying a smart contract uses gas. Try to click the drop down next to the "Debug" button in your Remix console below your code. It will expand your mined transaction and show more data. There you will see that the transaction actually consumed gas and there was a cost involved (see example screenshot below).

enter image description here

1

I think Remix makes an estimate of the gas cost for every transaction, simulating it, and sends about 30% more as gas limit, ignoring what is in the configuration. Only when it cannot estimate the cost, it will use the gas limit config.

For example, if the transaction reverts it will discard the estimate and send what is configured.

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.