ERC1155Burnable.sol 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v4.8.0-rc.0) (token/ERC1155/extensions/ERC1155Burnable.sol)
  3. pragma solidity ^0.8.0;
  4. import "../ERC1155.sol";
  5. /**
  6. * @dev Extension of {ERC1155} that allows token holders to destroy both their
  7. * own tokens and those that they have been approved to use.
  8. *
  9. * _Available since v3.1._
  10. */
  11. abstract contract ERC1155Burnable is ERC1155 {
  12. function burn(
  13. address account,
  14. uint256 id,
  15. uint256 value
  16. ) public virtual {
  17. require(
  18. account == _msgSender() || isApprovedForAll(account, _msgSender()),
  19. "ERC1155: caller is not token owner or approved"
  20. );
  21. _burn(account, id, value);
  22. }
  23. function burnBatch(
  24. address account,
  25. uint256[] memory ids,
  26. uint256[] memory values
  27. ) public virtual {
  28. require(
  29. account == _msgSender() || isApprovedForAll(account, _msgSender()),
  30. "ERC1155: caller is not token owner or approved"
  31. );
  32. _burnBatch(account, ids, values);
  33. }
  34. }