Migration to dVRF 3.0
This page introduces the new features of Supra dVRF 3.0 and provides migration steps. Clients are encouraged to migrate at their convenience before the VRF 2.0 contracts are phased out soon.
Why Migrate to dVRF 3.0?
Moving to VRF 3.0 offers several key advantages over the previous version, especially for users focused on reliability, customization, and future-proofing their integration.
dVRF 3.0 introduces major upgrades focused on reliability, configurability, and developer experience.
Who Needs to Migrate?
You need to migrate to VRF 3.0 if you are currently using VRF 2 and want access to VRF 3.0 features and improvements.
Migration Guide
Code for existing clients to Migrate
Before migrating, the client must withdraw their existing funds from the old Deposit contract.
The client must decide the following values:
maxGasPrice
— the maximum callback gas price they are willing to paymaxGasLimit
— the maximum callback gas limit with which the callback transaction can get executed.
The client can call getMinBalanceLimit(maxGasPrice, maxGasLimit) to compute their minimum balance required:
function getMinBalanceLimit(uint128 _maxGasPrice, uint128 _maxGasLimit)
external view returns (uint128
);
Interface to interact with the Deposit contract
interface IDeposit {
function getMinBalanceLimit(uint128 maxGasPrice, uint128 maxGasLimit) external view returns (uint128);
}
contract MigrateToVRF3 {
IDeposit public deposit; // The address of the Deposit contract (VRF 3.0)
constructor(address _deposit) {
deposit = IDeposit(_deposit);
}
/// @notice Get the minimum balance required.
function checkMinRequiredBalance(uint128 maxGasPrice, uint128 maxGasLimit) external view returns (uint128) {
return deposit.getMinBalanceLimit(maxGasPrice, maxGasLimit);
} }
Please refer to THIS REPO for Sample Contract with VRF3 Implementation.
Self-whitelisting Guide
Whitelist Your Consumer Contracts
The parameter this function takes is the User’s contract address along with callbackGasPrice
and callbackGasLimit
for the contract which should be smaller than the maxGasPrice
and maxGasLimit
respectively.
addContractToWhitelist(address _contractAddress, uint128 _callbackGasPrice, uint128 _callbackGasLimit)
Comparing dVRF 2 vs dVRF 3.0
Client Whitelisting
Manual only (admin-controlled)
Self-whitelisting enabled with maxGasPrice and maxGasLimit inputs
Min Balance Calculation
Static or fixed value
Dynamically computed
Upgradeable Contracts
Only Generator
Generator and Deposit
Custom Gas Config for Callbacks
Not available
Fully configurable per client and per contract (callbackGasPrice, callbackGasLimit)
Fund Locking for Pending Requests
Funds always withdrawable
Funds locked if there are pending RNG requests
Request Retry Mechanism
Not available
Failed RNG callbacks due to low balance retried for 48 hours
Backward Compatibility
Not applicable
Generator and Deposit allow compatibility with older structure
On chain storing calldata hash of request
Only validated on chain
Stored on chain and validated also on chain
Functions Introduced in dVRF 3
addClientToWhitelist(uint128, uint128)
Deposit
Allows new clients to self-whitelist, specifying their max gas price and gas limit.
getMinBalanceLimit(uint128, uint128)
Deposit
Returns the minimum balance required to maintain based on client’s gas settings.
migrateClient(uint128, uint128)
Deposit
Enables existing clients to migrate their subscription and settings from VRF 2 to VRF 3.0.
updateMinRequests(uint128)
Deposit
Admin sets the minimum number of expected RNG requests per client, used to compute minBalanceLimit.
updateVerificationGasValue(uint128)
Deposit
Admin sets the gas cost of BLS verification, a component in calculating minBalanceLimit.
removeClientFromWhitelist(address, bool)
Deposit
Removes a client and refunds their balance (or transfers to supraFund if forced).
updateCount(address)
Deposit
Tracks the number of RNG requests and responses per client (called by Generator).
setOldDepositContract(address)
Deposit
Sets the address of the previous deposit contract for migration support.
updateMigrationEndTime(uint256)
Deposit
Admin sets the deadline for migration from the old contract.
setSupraMinimumPerTx(uint256)
Generator
Admin function to set the minimum gas charged per RNG transaction attempt (even if the callback fails).
updateMaxGasPrice(uint128)
Deposit
Allows a whitelisted client to update their maxGasPrice, which impacts the minBalanceLimit.
updateMaxGasLimit(uint128)
Deposit
Allows a whitelisted client to update their maxGasLimit, which affects the minBalanceLimit.
updateCallbackGasPrice(address, uint128)
Deposit
Allows clients to set callbackGasPrice for specific contracts.
updateCallbackGasLimit(address, uint128)
Deposit
Allows clients to set callbackGasLimit for specific contracts.
Last updated