Pausable.sol 951 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 allow actions only when the contract IS paused
  13. */
  14. modifier whenNotPaused() {
  15. if (paused) throw;
  16. _;
  17. }
  18. /**
  19. * @dev modifier to allow actions only when the contract IS NOT paused
  20. */
  21. modifier whenPaused {
  22. if (!paused) throw;
  23. _;
  24. }
  25. /**
  26. * @dev called by the owner to pause, triggers stopped state
  27. */
  28. function pause() onlyOwner whenNotPaused returns (bool) {
  29. paused = true;
  30. Pause();
  31. return true;
  32. }
  33. /**
  34. * @dev called by the owner to unpause, returns to normal state
  35. */
  36. function unpause() onlyOwner whenPaused returns (bool) {
  37. paused = false;
  38. Unpause();
  39. return true;
  40. }
  41. }