I created a contract on remix and then deployed it. when I call any function there is an execution cost in gas. I also deployed the same contract on Ganache for testing. I find the execution cost in remix is 525424 gas but in Ganache, i found the gas used 1214584 gas. Is the execution costs in remix is accurate, Is it simulate the actual execution costs on etherum network? How can I know the execution cost in ganache?
-
2It's hard to say without the code and exact txs you used. Seeing as it is a contract deployment, a simple difference could be enabling/disabling optimization– Raghav SoodOct 10, 2018 at 18:59
-
If I want to estimate the execution cost in gas, can I depend on numbers shown in the remix?– MohamedOct 10, 2018 at 20:41
-
If you are deploying the exact same bytecode you are estimating against, it is reasonably accurate. If you make changes to configurations/optimizations/set values that change the code paths taken, then you will need to estimate again against the new state– Raghav SoodOct 10, 2018 at 20:45
-
Okay. I understand remix. Do you know how I get the gas cost in Ganache?. For me, I deployed the same Bytecode. But I do not how to get the actual execution cost on Ganache?– MohamedOct 10, 2018 at 20:48
-
Solc can output the gas estimates, the documentation has examples on how.– Raghav SoodOct 10, 2018 at 21:35