Last active
August 17, 2017 18:07
-
-
Save aunyks/6bfaef246d3f1bbe30020249e0c28e2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract MyERCToken { | |
mapping(address => uint256) balances; | |
// Note: This function returns a boolean value | |
// indicating whether the transfer was successful | |
function transfer(address _to, uint256 _amount) returns (bool success) { | |
// If the sender has sufficient funds to send | |
// and the amount is not zero, then send to | |
// the given address | |
if (balances[msg.sender] >= _amount | |
&& _amount > 0 | |
&& balances[_to] + _amount > balances[_to]) { | |
balances[msg.sender] -= _amount; | |
balances[_to] += _amount; | |
// Fire a transfer event for any | |
// logic that's listening | |
Transfer(msg.sender, _to, _amount); | |
return true; | |
} else { | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment