ERC20PausableUpgradeable.sol 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Pausable.sol)
  3. pragma solidity ^0.8.0;
  4. import "../ERC20Upgradeable.sol";
  5. import "../../../security/PausableUpgradeable.sol";
  6. import "../../../proxy/utils/Initializable.sol";
  7. /**
  8. * @dev ERC20 token with pausable token transfers, minting and burning.
  9. *
  10. * Useful for scenarios such as preventing trades until the end of an evaluation
  11. * period, or having an emergency switch for freezing all token transfers in the
  12. * event of a large bug.
  13. */
  14. abstract contract ERC20PausableUpgradeable is Initializable, ERC20Upgradeable, PausableUpgradeable {
  15. function __ERC20Pausable_init() internal onlyInitializing {
  16. __Pausable_init_unchained();
  17. }
  18. function __ERC20Pausable_init_unchained() internal onlyInitializing {
  19. }
  20. /**
  21. * @dev See {ERC20-_beforeTokenTransfer}.
  22. *
  23. * Requirements:
  24. *
  25. * - the contract must not be paused.
  26. */
  27. function _beforeTokenTransfer(
  28. address from,
  29. address to,
  30. uint256 amount
  31. ) internal virtual override {
  32. super._beforeTokenTransfer(from, to, amount);
  33. require(!paused(), "ERC20Pausable: token transfer while paused");
  34. }
  35. /**
  36. * This empty reserved space is put in place to allow future versions to add new
  37. * variables without shifting down storage in the inheritance chain.
  38. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  39. */
  40. uint256[50] private __gap;
  41. }