3

This is about the parameters that we need to provide at the time of source code verification on Etherscan. I have a bit idea about it but i am looking for some deep and clear explanation.

So my question is what are these parameters i.e runs and optimization all about. Answer can consist the detail about:

  • How they exactly affect the source code verification?
  • Why enabling optimization sometimes prevents smart contract verification?
  • Why we usually pass 200 to runs?
2

How they exactly affect the source code verification?

If you pass to Etherscan different parameters than the ones you've used when you compiled the contract and deployed it, then the verification might fail because those different parameters might lead Etherscan compilation to generate a different byte-code than the byte-code that your compilation has generated.

Why enabling optimization sometimes prevents smart contract verification?

If you compile your contract without optimization, but you enable optimization on Etherscan, then the output byte-code of your compilation and of Etherscan compilation might be different, in which case the verification will fail.

Why we usually pass 200 to runs?

Because this is the Solidity Compiler default value.

  • Thanks for the answer @goodvibration. Please update in the answer that what does optimization and runs signify? – Aniket Dec 17 '18 at 10:28
  • @A.K.: optimization can be either true or false, and it indicates whether or not the compiler should optimize the code. AFAIK, in our eco-system here (block-chain), 'optimize' translates to 'reduce gas consumption (in opposed to 'increase speed' or 'reduce memory consumption' on traditional eco-systems). optimization-runs indicates the number of iterations that the compiler should perform during the optimization process. – goodvibration Dec 17 '18 at 11:22
  • On every iteration, the compiler may improve the code a little bit more. Of course, at some point, depending on your specific code, there's no added value in increasing this value. You can find the minimum value of runs which yields maximum optimization, by trying different values, until you find a point where the output byte-code remains identical (binary-search would be ideal for that). Alternatively, you can just use a very large value to begin with. – goodvibration Dec 17 '18 at 11:22
  • You can read most or all of it in the official documentation. – goodvibration Dec 17 '18 at 11:27
  • @A.K.: You're welcome! – goodvibration Dec 17 '18 at 11:48

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.