On the one hand, protecting from over- and underflow is a must, and a widely used SafeMath library can help with that. SafeMath throw
s 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?