-
Notifications
You must be signed in to change notification settings - Fork 1
/
toss.sol
52 lines (41 loc) · 917 Bytes
/
toss.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
51
52
contract Toss {
address player;
uint8 chosenByUser;
string public result;
uint256 public toss;
address owner;
function Toss() {
owner = msg.sender;
}
function withdrawl() returns(string) {
if(msg.sender == owner) {
owner.send(this.balance);
return "Success";
} else {
throw;
}
}
function play(uint8 choice) returns(string) {
if(this.balance >= 19) {
// throw;
}
if(msg.value != 10) {
// Throw?
// Return all/some? Re-entrancy?
if(!player.send(msg.value)) {
throw;
}
return "To play please include 10 wei";
}
toss = now % 2;
chosenByUser = choice;
if(toss == choice) {
// Wait! What about re-entrancy?
player.send(19);
result = "Win";
} else {
result = "Loss";
}
return result;
}
}