ERC20Burnable.sol 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Burnable.sol)
  3. pragma solidity ^0.8.0;
  4. import "../ERC20.sol";
  5. import "../../../utils/Context.sol";
  6. /**
  7. * @dev Extension of {ERC20} that allows token holders to destroy both their own
  8. * tokens and those that they have an allowance for, in a way that can be
  9. * recognized off-chain (via event analysis).
  10. */
  11. abstract contract ERC20Burnable is Context, ERC20 {
  12. /**
  13. * @dev Destroys `amount` tokens from the caller.
  14. *
  15. * See {ERC20-_burn}.
  16. */
  17. function burn(uint256 amount) public virtual {
  18. _burn(_msgSender(), amount);
  19. }
  20. /**
  21. * @dev Destroys `amount` tokens from `account`, deducting from the caller's
  22. * allowance.
  23. *
  24. * See {ERC20-_burn} and {ERC20-allowance}.
  25. *
  26. * Requirements:
  27. *
  28. * - the caller must have allowance for ``accounts``'s tokens of at least
  29. * `amount`.
  30. */
  31. function burnFrom(address account, uint256 amount) public virtual {
  32. _spendAllowance(account, _msgSender(), amount);
  33. _burn(account, amount);
  34. }
  35. }