ERC1155Pausable.sol 1.1 KB

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