Pausable.sol 909 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. pragma solidity ^0.4.11;
  2. import "../ownership/Ownable.sol";
  3. /**
  4. * @title Pausable
  5. * @dev Base contract which allows children to implement an emergency stop mechanism.
  6. */
  7. contract Pausable is Ownable {
  8. event Pause();
  9. event Unpause();
  10. bool public paused = false;
  11. /**
  12. * @dev Modifier to make a function callable only when the contract is not paused.
  13. */
  14. modifier whenNotPaused() {
  15. require(!paused);
  16. _;
  17. }
  18. /**
  19. * @dev Modifier to make a function callable only when the contract is paused.
  20. */
  21. modifier whenPaused() {
  22. require(paused);
  23. _;
  24. }
  25. /**
  26. * @dev called by the owner to pause, triggers stopped state
  27. */
  28. function pause() onlyOwner whenNotPaused {
  29. paused = true;
  30. Pause();
  31. }
  32. /**
  33. * @dev called by the owner to unpause, returns to normal state
  34. */
  35. function unpause() onlyOwner whenPaused {
  36. paused = false;
  37. Unpause();
  38. }
  39. }