Moving business logic preconditions to the beginning of the function.

This commit is contained in:
Dan Phifer
2017-09-23 11:57:29 +08:00
parent 158a7a881d
commit e70dd18734
3 changed files with 7 additions and 6 deletions

View File

@ -21,6 +21,7 @@ contract BasicToken is ERC20Basic {
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);