Skip to content

Instantly share code, notes, and snippets.

@pvrego
Last active May 2, 2022 12:40
Show Gist options
  • Save pvrego/346eec78ad182cf80d8d7371791363a4 to your computer and use it in GitHub Desktop.
Save pvrego/346eec78ad182cf80d8d7371791363a4 to your computer and use it in GitHub Desktop.
Random Generator HPB
pragma solidity ^0.5.6;
contract HRNG {
function getRandom() public view returns (bytes32) {
return block.random;
}
}
// 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