neu-fi / regen-bingo

Monorepo for both backend and contract developments of Regen Bingo!
https://regen.bingo
2 stars 1 forks source link

Use Chainlink VRF V2 with Direct Funding Method #73

Closed hantuzun closed 1 year ago

hantuzun commented 1 year ago

It's the time to integrate Chainlink VRF.

The documentations are available on:

Here's the example contract getting randomness from Chainlink docs: https://remix.ethereum.org/#url=https://docs.chain.link/samples/VRF/VRFv2DirectFundingConsumer.sol

I suggest asking for the random number once in the startDrawPeriod function and recording a seed for the following reasons:

If we agree on this, we'd only need to modify startDrawPeriod() and add fulfillRandomWords(...). fulfillRandomWords(...) could store the random word as a variable. And then we could use that variable and nonces in drawNumber() only by changing the variables we put into the hash functions.

Design considerations:

@daggerhashimoto you should review this issue.