Created
December 20, 2016 22:02
-
-
Save RFV/d8a3acb86aa9557623bcc1d2bcae8819 to your computer and use it in GitHub Desktop.
Solidity Gambling Smart Contract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract Gamble { | |
function Gamble() { | |
owner = msg.sender; | |
address nameReg = 0x72ba7d8e73fe8eb666ea66babc8116a41bfb10e2; | |
nameReg.callstring32string32("register", "UltimateGamble"); | |
} | |
function gamble(uint luckyNumber) { | |
value = value+ msg.value; | |
hash randomness = sha3(block.prevhash ^ hash(msg.sender) ^ luckyNumber); | |
if (msg.value >= 1000000000000000000 && ((randomness & 0xff) < hash(0x20))) { | |
lostValue = lostValue + value / 2; | |
msg.sender.send(value - (value / 2)); | |
value = 0; | |
} | |
} | |
function withdraw() { | |
owner.send(lostValue); | |
lostValue = 0; | |
} | |
uint value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment