Skip to content

Instantly share code, notes, and snippets.

@Raz0r
Last active May 21, 2018 11:37
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 Raz0r/885f0983a133f3920d57dbc9dfe4b09d to your computer and use it in GitHub Desktop.
Save Raz0r/885f0983a133f3920d57dbc9dfe4b09d to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.16;
contract Azino777 {
function spin(uint256 bet) public payable {
require(msg.value >= 0.01 ether);
uint256 num = rand(100);
if(num == bet) {
msg.sender.transfer(this.balance);
}
}
//Generate random number between 0 & max
uint256 constant private FACTOR = 1157920892373161954235709850086879078532699846656405640394575840079131296399;
function rand(uint max) constant private returns (uint256 result){
uint256 factor = FACTOR * 100 / max;
uint256 lastBlockNumber = block.number - 1;
uint256 hashVal = uint256(block.blockhash(lastBlockNumber));
return uint256((uint256(hashVal) / factor)) % max;
}
function() public payable {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment