Created
October 21, 2021 20:57
-
-
Save vbalko/fc49f9515fac036fc5860f434e6b830f to your computer and use it in GitHub Desktop.
random function in solidity
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
/** | |
* @title Storage | |
* @dev Store & retrieve value in a variable | |
*/ | |
contract rand { | |
uint256 number; | |
function roll(uint _a, uint _b, uint _dx) public view returns (uint) { | |
return uint(keccak256(abi.encodePacked(block.timestamp, _a, _b)))%_dx + 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment