ERC1155Burnable.sol 997 B

12345678910111213141516171819202122232425262728
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/extensions/ERC1155Burnable.sol)
  3. pragma solidity ^0.8.19;
  4. import {ERC1155} from "../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. abstract contract ERC1155Burnable is ERC1155 {
  10. function burn(address account, uint256 id, uint256 value) public virtual {
  11. if (account != _msgSender() && !isApprovedForAll(account, _msgSender())) {
  12. revert ERC1155MissingApprovalForAll(_msgSender(), account);
  13. }
  14. _burn(account, id, value);
  15. }
  16. function burnBatch(address account, uint256[] memory ids, uint256[] memory values) public virtual {
  17. if (account != _msgSender() && !isApprovedForAll(account, _msgSender())) {
  18. revert ERC1155MissingApprovalForAll(_msgSender(), account);
  19. }
  20. _burnBatch(account, ids, values);
  21. }
  22. }