0

On the one hand, protecting from over- and underflow is a must, and a widely used SafeMath library can help with that. SafeMath throws in case of error.

On the other hand, ERC20 token functions are expected to return false on failure, not throw. This presentation advises against throwing in transfer and other ERC20 functions that return bool(success).

What is the proper way of protecting against integer errors in tokens while conforming to the API?

1 Answer 1

0

There's actually an issue in SafeMath's repo that has been there for a while which references this subject. https://github.com/OpenZeppelin/zeppelin-solidity/issues/435

There's also a PR submitted but not yet merged. https://github.com/OpenZeppelin/zeppelin-solidity/pull/468

I guess you could replace SafeMath for this code if you really need to make the token 100% compliant, or wait a while until they do merge that PR.

Your Answer

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

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