VRFCoordinatorV2Interface
Functions
getRequestConfig
Get configuration relevant for making requests
function getRequestConfig() external view returns (uint16, uint32, bytes32[] memory);
Returns
Name | Type | Description |
---|---|---|
<none> | uint16 | minimumRequestConfirmations global min for request confirmations |
<none> | uint32 | maxGasLimit global max for request gas limit |
<none> | bytes32[] | s_provingKeyHashes list of registered key hashes |
requestRandomWords
Request a set of random words.
function requestRandomWords(
bytes32 keyHash,
uint64 subId,
uint16 minimumRequestConfirmations,
uint32 callbackGasLimit,
uint32 numWords
) external returns (uint256 requestId);
Parameters
Name | Type | Description |
---|---|---|
keyHash | bytes32 | - Corresponds to a particular oracle job which uses that key for generating the VRF proof. Different keyHash's have different gas price ceilings, so you can select a specific one to bound your maximum per request cost. |
subId | uint64 | - The ID of the VRF subscription. Must be funded with the minimum subscription balance required for the selected keyHash. |
minimumRequestConfirmations | uint16 | - How many blocks you'd like the oracle to wait before responding to the request. See SECURITY CONSIDERATIONS for why you may want to request more. The acceptable range is [minimumRequestBlockConfirmations, 200]. |
callbackGasLimit | uint32 | - How much gas you'd like to receive in your fulfillRandomWords callback. Note that gasleft() inside fulfillRandomWords may be slightly less than this amount because of gas used calling the function (argument decoding etc.), so you may need to request slightly more than you expect to have inside fulfillRandomWords. The acceptable range is [0, maxGasLimit] |
numWords | uint32 | - The number of uint256 random values you'd like to receive in your fulfillRandomWords callback. Note these numbers are expanded in a secure way by the VRFCoordinator from a single random value supplied by the oracle. |
Returns
Name | Type | Description |
---|---|---|
requestId | uint256 | - A unique identifier of the request. Can be used to match a request to a response in fulfillRandomWords. |
createSubscription
Create a VRF subscription.
You can manage the consumer set dynamically with addConsumer/removeConsumer.
Note to fund the subscription, use transferAndCall. For example
LINKTOKEN.transferAndCall(
address(COORDINATOR),
amount,
abi.encode(subId));
function createSubscription() external returns (uint64 subId);
Returns
Name | Type | Description |
---|---|---|
subId | uint64 | - A unique subscription id. |
getSubscription
Get a VRF subscription.
function getSubscription(uint64 subId)
external
view
returns (uint96 balance, uint64 reqCount, address owner, address[] memory consumers);
Parameters
Name | Type | Description |
---|---|---|
subId | uint64 | - ID of the subscription |
Returns
Name | Type | Description |
---|---|---|
balance | uint96 | - LINK balance of the subscription in juels. |
reqCount | uint64 | - number of requests for this subscription, determines fee tier. |
owner | address | - owner of the subscription. |
consumers | address[] | - list of consumer address which are able to use this subscription. |
requestSubscriptionOwnerTransfer
Request subscription owner transfer.
function requestSubscriptionOwnerTransfer(uint64 subId, address newOwner) external;
Parameters
Name | Type | Description |
---|---|---|
subId | uint64 | - ID of the subscription |
newOwner | address | - proposed new owner of the subscription |
acceptSubscriptionOwnerTransfer
Request subscription owner transfer.
will revert if original owner of subId has not requested that msg.sender become the new owner.
function acceptSubscriptionOwnerTransfer(uint64 subId) external;
Parameters
Name | Type | Description |
---|---|---|
subId | uint64 | - ID of the subscription |
addConsumer
Add a consumer to a VRF subscription.
function addConsumer(uint64 subId, address consumer) external;
Parameters
Name | Type | Description |
---|---|---|
subId | uint64 | - ID of the subscription |
consumer | address | - New consumer which can use the subscription |
removeConsumer
Remove a consumer from a VRF subscription.
function removeConsumer(uint64 subId, address consumer) external;
Parameters
Name | Type | Description |
---|---|---|
subId | uint64 | - ID of the subscription |
consumer | address | - Consumer to remove from the subscription |
cancelSubscription
Cancel a subscription
function cancelSubscription(uint64 subId, address to) external;
Parameters
Name | Type | Description |
---|---|---|
subId | uint64 | - ID of the subscription |
to | address | - Where to send the remaining LINK to |
pendingRequestExists
function pendingRequestExists(uint64 subId) external view returns (bool);