I have a contract deployed both in test and main network and if i execute same method with same parameters, will gas used differ?

2 Answers 2


Yes, generally.

More precisely, there are three variables in play to make sure we don't get overconfident.

The obvious one is the different state. I would stress that a well-designed contract will not have any functions that vary wildly ... that is, the logic should be guaranteed to finish under a certain maximum cost. Unbounded iteration and recursion is an anti-pattern. If one follows that principle, then it shouldn't matter (that much) that are different states on different networks.

The next one is the compiler version. You should get the same bytecode from the same contract and compiler every time, so just be careful not to stray from that as you hop from network to network.

The last one is the gas cost for each operation. Those operations are spelled out in the bytecode, but the cost of each operation so specified is a property of the protocol. In fact, if hardware and other constraints change sufficiently to warrant a change in the price list, then implementation requires a fork. That means it's conceivable for different networks to be running different generations of the protocol and therefore compute slightly different gas costs to run the same transaction when everything else is equal.

Hope it helps.


It's a bit unclear what you're asking but the same contract deployed on a different network will not be identical.

The bytecode will be identical but the state will not be. Depending on the computations your methods are doing it's going to cost different gas.

TLDR; Yes, it will consume different gas

  • If the contract is same and if i am calling the same method with same parameters, will the computation process differ?
    – Madan
    Apr 17, 2018 at 14:22
  • It depends. If you're looping over a number of items and the contracts have different items it will cost differently Apr 17, 2018 at 14:23
  • Oh yes, but will it be the ideal case for a simple token transfer from one address to another?
    – Madan
    Apr 17, 2018 at 14:25
  • It's a high chance it will be different Apr 17, 2018 at 14:26

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.