logo
For any query reach us at
FREE PLAN

Signout

logo
C
Chainlink VRFby BuildBear Labs
Free

Description

The BuildBear Chainlink VRF Plugin allows developers to seamlessly integrate Chainlink VRF into their development workflow for random number generation without the use of any mock setups. For eg, if you have a Lottery Smart Contract which depends on the Random Number from Chainlink, you can install the Chainlink VRF plugin and call the Chainlink Contracts, as you (your contracts) would do on the Mainnet; there is NO NEED for you to set—up any mock contract or calls.

For detailed documentation on how to use Chainlink VRF v2.5, please refer to our tutorial or the Chainlink Documentation.

Features

  1. Supports Subscription Method to manage multiple Consumer Contracts with a Single subscription account funded with Link tokens.
  2. Use your existing Chainlink VRF Subscription or create a new one with ease.
  3. Supported networks include Ethereum, Arbitrum, Avalanche, BNB, and Polygon.

How to use

1. Install the plug-in to your Sandbox;    
2. Follow any of the methods below to either use your existing Subscription or set-up a new Subscription:

Option 1: Existing Subscription (Assumption: you are aware of how Chainlink VRF works)

If you have an existing Chainlink VRF Subscription on any of the existing mainnets (or public testnets), you can use your current Subscription ID.

If the Subscription is already funded on the mainnet, then your smart contract calls will work on BuildBear Sandboxes without any modification (i.e., exactly as they would function on the mainnet).

If the Subscription is NOT funded, you can fund the subscription using the LINK tokens in the exactly same manner as you would do on the mainnet. However, you can use the BuildBear Faucet to get the LINK tokens easily.

For your convenience, you can refer to the Fund Subscription (L33) section in this script.

Option 2: Create a New Subscription (Please read on how to use the Chainlink VRF from our tutorial or documentation)

Call createSubscription() in the VRF Coordinator Contract in your sandbox to create a new subscription and secure a Subscription ID. After the subscription, you need to fund the Subscription ID with LINK tokens by calling transferAndCall() to make random number requests. While funding, keep the following points in mind:

1. The account must have enough LINK token balance. You can use the BuildBear Faucet to get the LINK tokens easily. 
2. The value param in transferAndCall should be in the smallest denomination of LINK called a Juel i.e. 1 LINK = 1e18 Juel. 
3. The data param in transferAndCall must be subId in ABI encoded form as it expects calldata 
 

You can follow this script to automate the steps. For more details refer to the tutorial here.

3. Deploy the consumer contract and add the consumer contract to the VRF Coordinator (unless these were already done before the creation of the Sandbox).    
4. Request random words as you would do the Mainnet. 

Conclusion

Install the Chainlink VRF plugin in your sandbox to effortlessly get random values for your smart contracts, just as you would on mainnet or any supported network. In addition to the above, check out our beginner-friendly tutorial on How to Use Chainlink VRF.