-
-
Save krsnnik/1a8cbd863e43cd97753d3eb952be5de6 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
/** | |
* @dev See `IERC777.burn`. | |
* | |
* Also emits a `Transfer` event for ERC20 compatibility. | |
*/ | |
function burn(uint256 amount, bytes calldata data) external { | |
_burn(msg.sender, msg.sender, amount, data, ""); | |
} | |
/** | |
* @dev Burn tokens | |
* @param operator address operator requesting the operation | |
* @param from address token holder address | |
* @param amount uint256 amount of tokens to burn | |
* @param data bytes extra information provided by the token holder | |
* @param operatorData bytes extra information provided by the operator (if any) | |
*/ | |
function _burn( | |
address operator, | |
address from, | |
uint256 amount, | |
bytes memory data, | |
bytes memory operatorData | |
) | |
private | |
{ | |
require(from != address(0), "ERC777: burn from the zero address"); | |
_callTokensToSend(operator, from, address(0), amount, data, operatorData); | |
// Update state variables | |
_totalSupply = _totalSupply.sub(amount); | |
_balances[from] = _balances[from].sub(amount); | |
emit Burned(operator, from, amount, data, operatorData); | |
emit Transfer(from, address(0), amount); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment