3

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?

enter image description here enter image description here

  • 2
    It'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 Sood Oct 10 '18 at 18:59
  • If I want to estimate the execution cost in gas, can I depend on numbers shown in the remix? – Mohamed Oct 10 '18 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 Sood Oct 10 '18 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? – Mohamed Oct 10 '18 at 20:48
  • Solc can output the gas estimates, the documentation has examples on how. – Raghav Sood Oct 10 '18 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.