-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathPausable.sol
50 lines (40 loc) · 940 Bytes
/
Pausable.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
pragma solidity ^0.4.16;
import "./Trustable.sol";
contract Pausable is Trustable {
//To check if Token is paused
bool public paused;
//Block number on pause
uint256 public pauseBlockNumber;
//Block number on resume
uint256 public resumeBlockNumber;
event Pause(uint256 _blockNumber);
event Unpause(uint256 _blockNumber);
function pause()
public
onlyOwner
whenNotPaused
{
paused = true;
pauseBlockNumber = block.number;
resumeBlockNumber = 0;
Pause(pauseBlockNumber);
}
function unpause()
public
onlyOwner
whenPaused
{
paused = false;
resumeBlockNumber = block.number;
pauseBlockNumber = 0;
Unpause(resumeBlockNumber);
}
modifier whenNotPaused {
require(!paused);
_;
}
modifier whenPaused {
require(paused);
_;
}
}