Created
December 18, 2014 21:07
-
-
Save chriseth/fc9c6541920e0d8556ed to your computer and use it in GitHub Desktop.
Solidity Gambling 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