ERC1155Pausable.sol 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.7.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. * _Available since v3.1._
  13. */
  14. abstract contract ERC1155Pausable is ERC1155, Pausable {
  15. /**
  16. * @dev See {ERC1155-_beforeTokenTransfer}.
  17. *
  18. * Requirements:
  19. *
  20. * - the contract must not be paused.
  21. */
  22. function _beforeTokenTransfer(
  23. address operator,
  24. address from,
  25. address to,
  26. uint256[] memory ids,
  27. uint256[] memory amounts,
  28. bytes memory data
  29. )
  30. internal
  31. virtual
  32. override
  33. {
  34. super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
  35. require(!paused(), "ERC1155Pausable: token transfer while paused");
  36. }
  37. }