Created
May 13, 2021 19:36
-
-
Save percybolmer/e2a1665bdd2969c50e90c3b2e8ab6977 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* @notice transfer is used to transfer funds from the sender to the recipient | |
* This function is only callable from outside the contract. For internal usage see | |
* _transfer | |
* | |
* Requires | |
* - Caller cannot be zero | |
* - Caller must have a balance = or bigger than amount | |
* | |
*/ | |
function transfer(address recipient, uint256 amount) external returns (bool) { | |
_transfer(msg.sender, recipient, amount); | |
return true; | |
} | |
/** | |
* @notice _transfer is used for internal transfers | |
* | |
* Events | |
* - Transfer | |
* | |
* Requires | |
* - Sender cannot be zero | |
* - recipient cannot be zero | |
* - sender balance most be = or bigger than amount | |
*/ | |
function _transfer(address sender, address recipient, uint256 amount) internal { | |
require(sender != address(0), "DevToken: transfer from zero address"); | |
require(recipient != address(0), "DevToken: transfer to zero address"); | |
require(_balances[sender] >= amount, "DevToken: cant transfer more than your account holds"); | |
_balances[sender] = _balances[sender] - amount; | |
_balances[recipient] = _balances[recipient] + amount; | |
emit Transfer(sender, recipient, amount); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment