ERC1155Pausable.sol 988 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.6.0;
  3. import "./ERC1155.sol";
  4. import "../../utils/Pausable.sol";
  5. /**
  6. * @dev ERC1155 token with pausable token transfers, minting and burning.
  7. *
  8. * Useful for scenarios such as preventing trades until the end of an evaluation
  9. * period, or having an emergency switch for freezing all token transfers in the
  10. * event of a large bug.
  11. */
  12. abstract contract ERC1155Pausable is ERC1155, Pausable {
  13. /**
  14. * @dev See {ERC1155-_beforeTokenTransfer}.
  15. *
  16. * Requirements:
  17. *
  18. * - the contract must not be paused.
  19. */
  20. function _beforeTokenTransfer(
  21. address operator,
  22. address from,
  23. address to,
  24. uint256[] memory ids,
  25. uint256[] memory amounts,
  26. bytes memory data
  27. )
  28. internal virtual override
  29. {
  30. super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
  31. require(!paused(), "ERC1155Pausable: token transfer while paused");
  32. }
  33. }