ERC20Burnable.sol 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Burnable.sol)
  3. pragma solidity ^0.8.20;
  4. import {ERC20} from "../ERC20.sol";
  5. import {Context} from "../../../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 a `value` amount of tokens from the caller.
  14. *
  15. * See {ERC20-_burn}.
  16. */
  17. function burn(uint256 value) public virtual {
  18. _burn(_msgSender(), value);
  19. }
  20. /**
  21. * @dev Destroys a `value` amount of tokens from `account`, deducting from
  22. * the caller's 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. * `value`.
  30. */
  31. function burnFrom(address account, uint256 value) public virtual {
  32. _spendAllowance(account, _msgSender(), value);
  33. _burn(account, value);
  34. }
  35. }