-
Notifications
You must be signed in to change notification settings - Fork 1
/
dice1.sol
47 lines (32 loc) · 1.18 KB
/
dice1.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
pragma solidity ^0.4.0;
contract CoinFlip {
address owner;
uint payPercentaje = 75;
event Status(string _msg, address user, uint amount);
function CoinFlip() payable {
}
modifier onlyOwner {
if (msg.sender != owner) {
revert();
} else {
_;
}
}
function FlipCoin() payable {
if((block.timestamp % 2) == 0) {
if(this.balance < ((msg.value*payPercentaje)/100)) {
Status('Congratulations, You won! Sry, we didnt have enought Money to pay you, we pay you all the remaining balance of this contract', msg.sender, this.balance);
msg.sender.transfer(this.balance);
} else {
msg.sender.transfer(msg.value * (100 + payPercentaje)/100);
Status('Congratulations, You won!', msg.sender, msg.value * (100 + payPercentaje)/100);
}
} else {
Status('We are sorry, you lose, try Again to recover your money', msg.sender, msg.value);
}
}
function kill() onlyOwner {
Status('Contracted Killed, not longer available to use', msg.sender, this.balance);
suicide(owner);
}
}