Quick Start
Last updated
Last updated
In order to get your VRF up and running you will need to first make your contract VRF Compatible.
Ensure you have either or set up in your development environment.
Depending on your environment, use the following commands to import the Gelato VRF contracts:
For Hardhat users:
Clone the repo
Install dependencies yarn install
Fill in .env
with variables in .env.example
For Foundry users: forge install gelatodigital/vrf-contracts --no-commit
GelatoVRFConsumerBase
ContractThe recommended approach to integrate Gelato VRF is by inheriting from the GelatoVRFConsumerBase
smart contract. Here's a simple example to help you set it up:
To request randomness, call the _requestRandomness()
function. You should protect the call since it will take from your 1Balance. The data
argument will be passed back to you by the W3F.
Finally, implement the callback function.
When you're ready to deploy your Gelato VRF-compatible contract, an important step is to include the dedicated msg.sender
as a constructor parameter. This ensures that your contract is set up to work with the correct operator for fulfilling the randomness requests.. It's crucial for ensuring that only authorized requests are processed.
Before we dive into requesting randomness, it's crucial to understand the role of 1Balance
in using Gelato VRF. The Gelato VRF services necessitate that your Gelato balance is sufficiently funded. This balance caters to Gas fees and rewards Gelato Nodes for their computational tasks. For details about costs and funding your account, do visit our .
Before deploying, visit the . There, you will find the specific dedicated msg.sender
address assigned for your deployer address. This address is crucial for the security and proper functioning of your VRF requests. Learn more about it at
and once you have your contract ready & deployed, grab the address and .