VRFCoordinatorV2Interface

Git Source

Functions

getRequestConfig

Get configuration relevant for making requests

function getRequestConfig() external view returns (uint16, uint32, bytes32[] memory);

Returns

NameTypeDescription
<none>uint16minimumRequestConfirmations global min for request confirmations
<none>uint32maxGasLimit 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

NameTypeDescription
keyHashbytes32- 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.
subIduint64- The ID of the VRF subscription. Must be funded with the minimum subscription balance required for the selected keyHash.
minimumRequestConfirmationsuint16- 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].
callbackGasLimituint32- 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]
numWordsuint32- 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

NameTypeDescription
requestIduint256- 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

NameTypeDescription
subIduint64- 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

NameTypeDescription
subIduint64- ID of the subscription

Returns

NameTypeDescription
balanceuint96- LINK balance of the subscription in juels.
reqCountuint64- number of requests for this subscription, determines fee tier.
owneraddress- owner of the subscription.
consumersaddress[]- list of consumer address which are able to use this subscription.

requestSubscriptionOwnerTransfer

Request subscription owner transfer.

function requestSubscriptionOwnerTransfer(uint64 subId, address newOwner) external;

Parameters

NameTypeDescription
subIduint64- ID of the subscription
newOwneraddress- 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

NameTypeDescription
subIduint64- ID of the subscription

addConsumer

Add a consumer to a VRF subscription.

function addConsumer(uint64 subId, address consumer) external;

Parameters

NameTypeDescription
subIduint64- ID of the subscription
consumeraddress- New consumer which can use the subscription

removeConsumer

Remove a consumer from a VRF subscription.

function removeConsumer(uint64 subId, address consumer) external;

Parameters

NameTypeDescription
subIduint64- ID of the subscription
consumeraddress- Consumer to remove from the subscription

cancelSubscription

Cancel a subscription

function cancelSubscription(uint64 subId, address to) external;

Parameters

NameTypeDescription
subIduint64- ID of the subscription
toaddress- Where to send the remaining LINK to

pendingRequestExists

function pendingRequestExists(uint64 subId) external view returns (bool);