8

I have 1 contract deploying on test net, let say it use 300,000 gas for executing 1 function.

On main net, this contract will cost 300,000 gas per function also?

Thanks

1 Answer 1

7

Yes, the gas limit and gas used by the transaction will remain the same across networks, including the main net. This is because operations on the EVM have a defined set of costs associated to them, which is implemented the same on the test networks as well. You can also test this between two different test networks, like Ropsten and Rinkeby.

What can change your transaction fee is the gas price you set for that transaction. Where if you set a higher gas price, the transaction fee will be higher as well, since it's a product of the gas limit and the gas price.

3
  • This is not always correct. For example if test networks have different contracts (or no contracts) deployed at addresses that the logic depends on. Or if the testnetwork already are using a newer hardfork with different gas costs. Or if the other network defines completely different gas costs (e.g. L2 chains).
    – Richard
    Jan 4 at 14:11
  • 1
    @Richard the chance of this to happen is extremely low. Jan 29 at 6:42
  • 1
    With the current network landscape this is quite common. BSC uses an older hardfork therefore storage access is quite a lot cheaper. Arbitrum/ Optimism have a different cost model therefore you see differences. There are so many evm chains that assuming the same gas costs are valid everywhere is naive.
    – Richard
    Jan 29 at 10:11

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.