Skip to content

Instantly share code, notes, and snippets.

@RFV
Created December 20, 2016 22:02
Show Gist options
  • Save RFV/d8a3acb86aa9557623bcc1d2bcae8819 to your computer and use it in GitHub Desktop.
Save RFV/d8a3acb86aa9557623bcc1d2bcae8819 to your computer and use it in GitHub Desktop.
Solidity Gambling Smart 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