VRFBeacon
VRFBeacon
A contract that acts as a central beacon for fetching random numbers
from Chainlink VRF. Multiple requests within an EPOCH_PERIOD (as defined by
VRFBeacon deployer) will be coupled into one request to VRFCoordiantorV2.
An EPOCH_PERIOD is simply a block range.
Consumers of VRFBeacon will use the one random number as a seed to generate
another random number for the contract's own use case.
Fulfilled
event Fulfilled(uint256 requestId, uint256 randomNumber)
Requested
event Requested(uint256 requestId)
COORDINATOR
contract VRFCoordinatorV2Interface COORDINATOR
keyHash
bytes32 keyHash
s_subscriptionId
uint64 s_subscriptionId
callbackGasLimit
uint32 callbackGasLimit
numWords
uint32 numWords
blockNumberToRequestId
mapping(uint256 => uint256) blockNumberToRequestId
requestIdToRandomness
mapping(uint256 => uint256) requestIdToRandomness
constructor
constructor(uint64 _subscriptionId, address _vrf, bytes32 _keyHash, uint32 _callbackGasLimit, uint8 _epochPeriod) public
Constructor inherits VRFConsumerBase
getRequestId
function getRequestId(uint256 blockNumber) external view returns (uint256 requestId)
| Name | Type | Description |
|---|---|---|
| blockNumber | uint256 | in which request was made |
| Name | Type | Description |
|---|---|---|
| requestId | uint256 | of the EPOCH_PERIOD that blockNumber is in |
getRandomness
function getRandomness(uint256 blockNumber) external view returns (uint256 randomness)
| Name | Type | Description |
|---|---|---|
| blockNumber | uint256 | in which request was made |
| Name | Type | Description |
|---|---|---|
| randomness | uint256 | if not fulfilled yet returns 0 |
requestRandomness
function requestRandomness() public returns (uint256, uint256)
Requests randomness from a block hash
fulfillRandomWords
function fulfillRandomWords(uint256 requestId, uint256[] randomWords) internal
Callback function used by VRF Coordinator