Tutorial

Getting Random Numbers With Chainlink VRF

12 steps

In this tutorial, we’ll be covering one of Chainlink’s core offerings - the Chainlink VRF. With this powerful service, we have access to a provably fair and verifiable random number generator that can be used to introduce randomness to our smart contracts. We’ll go through the mechanism behind it as well as create a smart contract to see how this service works first-hand.

Helpful prior knowledge

Solidity


Learning Outcomes

By the end of this tutorial, you will be able to:

  • Understand why VRF services are needed in blockchain systems
  • Describe how Chainlink VRF v2 works
  • Request for random values using Chainlink VRF v2

Tutorial Steps

Total steps: 12

  • Step 1: Understanding the Problem
  • Step 2: Introduction to Chainlink VRF
  • Step 3: Situations Where Chainlink VRF Is Used
  • Step 4: Two Methods To Request For Randomness
  • Step 5: Supported Networks
  • Step 6: Request & Receive Data Cycle
  • Step 7: ConsumingContract.sol - VRF Wrapper & Pre-Configured Values
  • Step 8: ConsumingContract.sol - constructor() & requestRandomWords()
  • Step 9: ConsumingContract.sol - fulfillRandomWords() & getrequestStatus()
  • Step 10: Getting Goerli Testnet Tokens
  • Step 11: Requesting Random Values
  • Step 12: Fetching Random Values

Help Center Need help?

Find articles to support you through your journey or chat with our support team.

Help Center