Crypto Waitlist

Lottery Smart Contract Tutorial Part II – Get a verifiable random number with Chainlink VRF

Join Daily Airdrop

In this smart conract tutorial we use Chainlink VRF to improve the lottery smart contract that we created in Part I by replacing the pseudo-random number generator code with a true, verifiable random number.

Chainlink is a decentralized blockchain oracle network built on Ethereum.

Part III – Build a UI for this smart contract using Web3js:

Source code for this tutorial:

Chainlink docs:

Join Daily Airdrop

Rinkeby testnet faucet:

LINK faucet: (select Rinkeby testnet):


Related Articles


  1. I am getting this error. "Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?

    execution reverted { "originalError": { "code": 3, "data": "0x8129bbcd", "message": "execution reverted" } }" any help.

  2. dude, u really need to learn some English spelling!!! come on, tons of spelling mistakes in all of your videos hahahaha

  3. Could anyone refer me to some documentation to create a lottery for ERC 20 tokens? I am wondering how to modify this smart contract to reach what I am looking for. I am willing to learn, so no need for the full code (unless you have one handy ahah).

    In this serie we focus a lot on ETH transaction on mainnet, but I believe for ERC 20, 721 and others ; there might be different ways of coding. Thanks in advance for guiding me.

  4. 26:02 i keep getting this error after i sent LINK to contract address
    "originalError": {

    "code": 3,

    "data": "0x8129bbcd",

    "message": "execution reverted"

  5. can you make same tutorial for VRFV2? and instead in remix, can you show it in local editor, deploy it to testnet, and then fund the contract using code instead metamask extension?

  6. Thank you! These tutorials are amazing! I appreciate you leaving in the parts where you try to figure out what went wrong, they definitely help.

  7. Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? execution reverted { "originalError": { "code": 3, "data": "0x8129bbcd", "message": "execution reverted" } }

  8. Hey there, I have studies this code for about two weeks now. And I can confirm that it has a major flaw, first the function for fulfillRandomness is not defined that is why you get that warning. You do not need it but if your are trying to do things like the Mod of something you will need it. Also the reason mod.add did not work is because it is not defined like that, you just use a percentage it works like a charm. Thank you for putting this together I learned a lot from it!

  9. this contract part function payWinner maybe happen DoS with Failed Call hack i think ,
    What is the solution to prevent this from happening?

  10. Kudos sir you are doing a tremendous job…all i want is rinkeby faucet to work 😭😭😭😭

  11. hi, I got this error while entering the 2nd and 3rd account. Any way to fix it?

    transact to Lottery.enter errored: Invalid parameters: must provide an Ethereum address.

  12. Really loved the way you didn't edit the video part when you got the errors, it actually helps. Thanks for the tutorial 🙂

  13. Would you please share the source/Github repo if it's applicable? Thank you so mush!

  14. Great video, only one that explains this process well. I recommend that in the future you edit out the portions of the video where you are tying to figure out why something isn't working. Becuase it takes time from the video (21:5823:30) and it makes you seem less knowledgeable ( no offense here) just saying edit them out and then make a comment saying: oh if you get this mistake, this is how you would solve it.

Back to top button