forked from crytic/building-secure-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolution.sol
46 lines (37 loc) · 1.15 KB
/
solution.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
/// @notice there are two ways to run this contract
/// @dev first way to run: $ echidna-test solution.sol --test-mode assertion --contract Token
/// @dev second way to run: $ echidna-test solution.sol --config config.yaml --contract Token
contract Ownership {
address owner = msg.sender;
function Owner() public {
owner = msg.sender;
}
modifier isOwner() {
require(owner == msg.sender);
_;
}
}
contract Pausable is Ownership {
bool is_paused;
modifier ifNotPaused() {
require(!is_paused);
_;
}
function paused() public isOwner {
is_paused = true;
}
function resume() public isOwner {
is_paused = false;
}
}
contract Token is Pausable {
mapping(address => uint256) public balances;
function transfer(address to, uint256 value) public ifNotPaused {
uint256 initial_balance_from = balances[msg.sender];
uint256 initial_balance_to = balances[to];
balances[msg.sender] -= value;
balances[to] += value;
assert(balances[msg.sender] <= initial_balance_from);
assert(balances[to] >= initial_balance_to);
}
}