Pausable.sol 654 B

12345678910111213141516171819202122232425262728293031323334353637
  1. pragma solidity ^0.4.8;
  2. import "../ownership/Ownable.sol";
  3. /*
  4. * Pausable
  5. * Abstract contract that allows children to implement an
  6. * emergency stop mechanism.
  7. */
  8. contract Pausable is Ownable {
  9. bool public stopped;
  10. modifier stopInEmergency {
  11. if (!stopped) {
  12. _;
  13. }
  14. }
  15. modifier onlyInEmergency {
  16. if (stopped) {
  17. _;
  18. }
  19. }
  20. // called by the owner on emergency, triggers stopped state
  21. function emergencyStop() external onlyOwner {
  22. stopped = true;
  23. }
  24. // called by the owner on end of emergency, returns to normal state
  25. function release() external onlyOwner onlyInEmergency {
  26. stopped = false;
  27. }
  28. }