RandomizerRNG

Git Source

Inherits: RNG

State Variables

governor

address public governor;

callbackGasLimit

uint256 public callbackGasLimit = 50000;

randomizer

IRandomizer public randomizer;

randomNumbers

mapping(uint256 => uint256) public randomNumbers;

requesterToID

mapping(address => uint256) public requesterToID;

Functions

onlyByGovernor

modifier onlyByGovernor();

constructor

Constructor.

constructor(IRandomizer _randomizer, address _governor);

Parameters

NameTypeDescription
_randomizerIRandomizerRandomizer contract.
_governoraddressGovernor of the contract.

changeGovernor

Changes the governor of the contract.

function changeGovernor(address _governor) external onlyByGovernor;

Parameters

NameTypeDescription
_governoraddressThe new governor.

setCallbackGasLimit

Change the Randomizer callback gas limit.

function setCallbackGasLimit(uint256 _callbackGasLimit) external onlyByGovernor;

Parameters

NameTypeDescription
_callbackGasLimituint256the new limit.

setRandomizer

Change the Randomizer address.

function setRandomizer(address _randomizer) external onlyByGovernor;

Parameters

NameTypeDescription
_randomizeraddressthe new Randomizer address.

randomizerWithdraw

Allows the governor to withdraw randomizer funds.

function randomizerWithdraw(uint256 _amount) external onlyByGovernor;

Parameters

NameTypeDescription
_amountuint256Amount to withdraw in wei.

requestRandomness

Request a random number. The id of the request is tied to the sender.

function requestRandomness(uint256) external override;

randomizerCallback

Callback function called by the randomizer contract when the random value is generated.

function randomizerCallback(uint256 _id, bytes32 _value) external;

receiveRandomness

Return the random number.

function receiveRandomness(uint256) external view override returns (uint256 randomNumber);

Returns

NameTypeDescription
randomNumberuint256The random number or 0 if it is not ready or has not been requested.