VRF Consumer

This page guides you through an example of consuming randomness from your consumer contract. The example consumer contract on the test network is at the GitHub repositoryarrow-up-right

As you can see in the VRFConsumerSamplearrow-up-right contract, we must create a variable to store

  • Subscription ID: you can get this after creating a subscription via our website

  • VRF Address: you can get the address from this page

  • Key Hash: you can get the key hash from this page

Requirements

function fulfillRandomWords(uint256 _requestId, uint256[] memory _randomWords) internal override

To get randomness, you must call the function called requestRandomWords() to the VRF coordinator by sending these parameters:

  • keyHash: you can get the key hash from this page

  • subscriptionId: your subscription id

  • requestConfirmations: the amount of block to confirm the transaction.

  • callbackGasLimit: gas limit when VRF node calls your fulfillRandomWords function

  • numWords: the amount of randomness

circle-info

Make sure your subscription has enough KDEV funding before requesting

Last updated