0

There are a lot of tools to prepare JavaScript/CSS code for production, e.g. to minimize, to convert ES8 code to ES5. Is there a tool to automatically apply SafeMath library to a .sol file?

The problem is that .add(), .mul(), etc. are much less readable than +, -, +=, etc. It takes much more time to edit and understand the source code with .add()'s instead of +'s. But the task of converting + to .add() doesn't require any intelligence and could be done by a build script. Does such a script exist (something like babel but for Solidity)?

  • How is that gonna help? The contract will be eventually deployed and verified with its "real" code, i.e., you'll be seeing add and mul, not + and *. – goodvibration Jul 2 at 13:06
  • E.g. I've been developing my contract with + and * (because + and * are just faster to type than .add, .mul() and a lot of nested parentheses) and now I'm ready to deploy it. It'd take a couple of hours to replace all + and - manually. – traxium Jul 2 at 13:36
  • You do realize that not necessarily should you replace every arithmetic operator in your code with a function-call, right? That could end up being a huge waste of gas. You should consider each operation separately, and determine whether or not it needs to be "secured". – goodvibration Jul 2 at 13:40

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.