Last active
May 21, 2018 11:37
-
-
Save Raz0r/885f0983a133f3920d57dbc9dfe4b09d to your computer and use it in GitHub Desktop.
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
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