Skip to content

Instantly share code, notes, and snippets.

@chriseth
Created December 18, 2014 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriseth/fc9c6541920e0d8556ed to your computer and use it in GitHub Desktop.
Save chriseth/fc9c6541920e0d8556ed to your computer and use it in GitHub Desktop.
Solidity Gambling Contract
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