1

When looking online, I see some answers that there is no use for SafeMath, but I still see some contracts that use it. Is it necessary, or are there any other benefits?

2 Answers 2

2

One more use: projects which upgrade from an older version (or a new project which forks an older project). If the old project used SafeMath, it may be just easier to keep using it in the new version as well, instead of modifying all the code.

1

SafeMath has try variants of the operators, which return 0 instead of reverting if an overflow happen. That's about the only benefit of using SafeMath post-0.8 i can think of.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.