Created
December 2, 2018 02:00
-
-
Save yhuag/70f0f3477ce19001b45303430951c0ed 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.21; | |
contract Random { | |
function getBlockNum() public constant returns (uint) { | |
return block.number; | |
} | |
function getNow() public constant returns (uint) { | |
return now; | |
} | |
function getNow2() public constant returns (uint) { | |
return block.timestamp; | |
} | |
function randNow(uint min, uint max) public constant returns (uint) { | |
return (getNow() % (max - min)) + min; | |
} | |
function randHash(uint min, uint max) public constant returns (uint){ | |
bytes32 hash = keccak256(getNow()); | |
return (uint(hash) % (max - min)) + min; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment