-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoinFlip.sol
More file actions
42 lines (34 loc) · 1.07 KB
/
CoinFlip.sol
File metadata and controls
42 lines (34 loc) · 1.07 KB
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
pragma solidity ^0.4.0;
//Casino game coinflip in which users can bet
contract CoinFlip{
address owner;
uint payPercentage=190;
event Status(string msg,address user,uint amount);
function CoinFlip() payable{
owner=msg.sender;
}
function FlipCoin() payable{
if((block.timestamp%2)==0){
if(this.balance<((msg.value*payPercentage)/100)){
Status("Congratulations we dont have that much money",msg.sender,this.balance);
msg.sender.transfer(this.balance);
}else{
Status("Congratulations",msg.sender,(msg.value*payPercentage)/100);
msg.sender.transfer((msg.value*payPercentage)/100);
}
}else{
Status("sorry you lose,try again",msg.sender,msg.value);
}
}
modifier onlyOwner(){
if(owner!=msg.sender){
throw;
}else{
_;
}
}
function kill() onlyOwner{
Status("Contract killed",msg.sender,this.balance);
suicide(owner);
}
}