Skip to content

Instantly share code, notes, and snippets.

@austintgriffith
Created March 9, 2018 00:23
Show Gist options
  • Select an option

  • Save austintgriffith/b3ce938961f821b8194094dba7562bc5 to your computer and use it in GitHub Desktop.

Select an option

Save austintgriffith/b3ce938961f821b8194094dba7562bc5 to your computer and use it in GitHub Desktop.
function getRandom(uint8 maxRan, uint8 index, address priAddress) constant public returns(uint8) {
uint256 genNum = uint256(block.blockhash(block.number-1)) + uint256(priAddress);
for (uint8 i = 0; i < index && i < 6; i ++) {
genNum /= 256;
}
return uint8(genNum % maxRan);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment