Skip to content

Instantly share code, notes, and snippets.

@DoguD
Created September 27, 2022 09:01
Show Gist options
  • Save DoguD/5428df6fd8cf42784138c21ec090b2e1 to your computer and use it in GitHub Desktop.
Save DoguD/5428df6fd8cf42784138c21ec090b2e1 to your computer and use it in GitHub Desktop.
// Source: https://blog.finxter.com/how-to-generate-random-numbers-in-solidity/
pragma solidity ^0.8.0;
contract RandomNumbers{
function random(uint number) public view returns(uint){
return uint(keccak256(abi.encodePacked(block.timestamp,block.difficulty,
msg.sender))) % number;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment