Other Functions
Beyond requesting random numbers, Supra dVRF provides additional functions for managing your account, monitoring balances, and configuring contract settings. These utility functions help you maintain your VRF integration and optimize your random number generation workflow.
Interact with deposit contract
The simplest way to interact with the deposit contract is through Remix IDE.
Setup in Remix IDE
Go to Remix IDE & create a file with name
IDepositContract.sol
Paste the following interface code in the file:
interface IDepositContract {
function depositFundClient() external payable;
function addContractToWhitelist(address _contractAddress, uint128 _callbackGasPrice, uint128 _callbackGasLimit) external;
function removeContractFromWhitelist(address _contractAddress) external;
function withdrawFundClient(uint128 _amount) external;
function updateMaxGasPrice(uint128 _maxGasPrice) external;
function updateMaxGasLimit(uint128 _maxGasLimit) external;
function updateCallbackGasPrice(address _contractAddress, uint128 _callbackGasPrice) external;
function updateCallbackGasLimit(address _contractAddress, uint128 _callbackGasLimit) external;
function checkClientFund(address _clientAddress) external view returns (uint128);
function checkMinBalanceClient(address _clientAddress) external view returns (uint128);
function countTotalWhitelistedContractByClient(address _clientAddress) external view returns (uint256);
function getSubscriptionInfoByClient(address _clientAddress) external view returns (uint64, bool);
function isMinimumBalanceReached(address _clientAddress) external view returns (bool);
function listAllWhitelistedContractByClient(address _clientAddress) external view returns (address[] memory);
}
Navigate to the "Deploy & run Transactions" tab in Remix
Paste the Deposit Contract Address into the text box beside the "At Address" button & press the At Address button
You will find the instance for the Deposit Contract created, which you can use to interact with the contract features
Essential Functions
Contract Management
addContractToWhitelist
Whitelists your contract for requesting random numbers
_contractAddress
: Contract address (not EOA)
_callbackGasPrice
: Max gas price for callbacks (≤ maxGasPrice)
_callbackGasLimit
: Max gas limit (≤ maxGasLimit)
-
Call after deploying your requester contract
removeContractFromWhitelist
Removes contract from whitelist
_contractAddress
: Whitelisted contract address to remove
-
Use when contract no longer needed
Fund Management
depositFundClient
Deposits funds for callback transactions
None (payable function)
-
Must call before requesting random numbers. Keep balance above minimum
withdrawFundClient
Withdraws funds from account
_amount
: Amount to withdraw (≤ deposited balance)
-
Cannot exceed available balance
Gas Configuration
updateMaxGasPrice
Updates maximum gas price for callbacks
_maxGasPrice
: New max gas price (> 0)
-
Also updates minimum balance requirement
updateMaxGasLimit
Updates maximum gas limit for contracts
_maxGasLimit
: New max gas limit (> 0)
-
Also updates minimum balance requirement
updateCallbackGasPrice
Updates gas price for specific contract
_contractAddress
: Whitelisted contract
_callbackGasPrice
: New gas price (> 0)
-
Contract-specific setting
updateCallbackGasLimit
Updates gas limit for specific contract
_contractAddress
: Whitelisted contract
_callbackGasLimit
: New gas limit (> 0)
-
Contract-specific setting
Balance Information
checkClientFund
Returns total available balance
_clientAddress
: Whitelisted wallet address (EOA only)
uint128
Your deposited funds
checkMinBalanceClient
Returns minimum required balance
_clientAddress
: Whitelisted wallet address
uint128
Minimum balance threshold
isMinimumBalanceReached
Checks if balance is at/below minimum
_clientAddress
: Whitelisted wallet address
bool
true
if balance ≤ minimum, false
otherwise
Contract Information
countTotalWhitelistedContractByClient
Returns number of whitelisted contracts
_clientAddress
: Whitelisted wallet address
uint256
Total contract count
listAllWhitelistedContractByClient
Returns all whitelisted contract addresses
_clientAddress
: Whitelisted wallet address
address[]
Array of contract addresses
getSubscriptionInfoByClient
Returns subscription details
_clientAddress
: Whitelisted wallet address
uint64, bool
Subscription end timestamp, SNAP program status
Important Notes
Supra runs monitoring scripts that will alert you when a fund refill is required
Your funds are used to pay transaction fees for VRF response callbacks
Always ensure your total balance remains well above the minimum requirement to avoid request failures
Contract addresses and EOA addresses serve different purposes - use the correct type for each function
These functions provide comprehensive control over your Supra dVRF integration, allowing you to manage funds, monitor usage, and configure your setup according to your application's needs.
Last updated