Last active
May 2, 2022 12:40
-
-
Save pvrego/346eec78ad182cf80d8d7371791363a4 to your computer and use it in GitHub Desktop.
Random Generator HPB
This file contains hidden or 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.5.6; | |
contract HRNG { | |
function getRandom() public view returns (bytes32) { | |
return block.random; | |
} | |
} |
This file contains hidden or 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: Unlicensed | |
pragma solidity ^0.8.4; | |
abstract contract HRNG { | |
function getRandom() public view virtual returns (bytes32); | |
} | |
contract RetrieveRandom { | |
address hrngAddr; | |
HRNG hrng; | |
constructor (address hrngaddr) { | |
hrngAddr = hrngaddr; | |
hrng = HRNG(hrngAddr); | |
} | |
function retrieveNumber() public view returns (uint256) { | |
uint256 random = uint256(hrng.getRandom()); | |
return random; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment