I've noticed a discrepancy between the gas cost to deploy our contracts locally and on mainnet. I would have guessed that they should cost exactly the same.

Does anyone know why this happens?

  • 3
    In the past forks have altered the price of some opcodes, if your private blockchain didn't enable the it might be using the old prices. Another reason can be if your contract make calls to other contracts. And obviously contracts compiled with different versions of solidity compiler might generate different code. – Ismael Mar 31 '18 at 17:55
  • Check here - possible duplicate ethereum.stackexchange.com/questions/45923/… – Madan Apr 18 '18 at 7:18

As highlighted here, there are 3 Main Factors:

  1. Variable State (unbounded iteration leaves room for uncertainty)
  2. Compiler Version (different compilers will produce different bytecode)
  3. Gas Cost (same protocol version cannot be guaranteed between networks)

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.