Skip to Content

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 - EVM networks

The simplest way to interact with the deposit contract is through Remix IDE.

Setup in Remix IDE

  1. Go to Remix IDE & create a file with name IDepositContract.sol
  2. 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); }
  1. Navigate to the “Deploy & run Transactions” tab in Remix
  2. Paste the Deposit Contract Address into the text box beside the “At Address” button & press the At Address button
  3. You will find the instance for the Deposit Contract created, which you can use to interact with the contract features

Essential Functions

FunctionPurposeParametersReturnsNotes
Contract Management
addContractToWhitelistWhitelists 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
removeContractFromWhitelistRemoves contract from whitelist_contractAddress Whitelisted contract address to remove-Use when contract no longer needed
Fund Management
depositFundClientDeposits funds for callback transactionsNone (payable function)-Must call before requesting random numbers. Keep balance above minimum
withdrawFundClientWithdraws funds from account_amount: Amount to withdraw (≤ deposited balance)-Cannot exceed available balance
Gas Configuration
updateMaxGasPriceUpdates maximum gas price for callbacks_maxGasPrice New max gas price (> 0)-Also updates minimum balance requirement
updateMaxGasLimitUpdates maximum gas limit for contracts_maxGasLimit New max gas limit (> 0)-Also updates minimum balance requirement
updateCallbackGasPriceUpdates gas price for specific contract_contractAddress Whitelisted contract _callbackGasPrice: New gas price (> 0)-Contract-specific setting
updateCallbackGasLimitUpdates gas limit for specific contract_contractAddress Whitelisted contract _callbackGasLimit: New gas limit (> 0)-Contract-specific setting
Balance Information
checkClientFundReturns total available balance_clientAddress Whitelisted wallet address (EOA only)uint128Your deposited funds
checkMinBalanceClientReturns minimum required balance_clientAddress Whitelisted wallet addressuint128Minimum balance threshold
isMinimumBalanceReachedChecks if balance is at/below minimum_clientAddress Whitelisted wallet addressbooltrue if balance ≤ minimum, false otherwise
Contract Information
countTotalWhitelistedContractByClientReturns number of whitelisted contracts_clientAddress Whitelisted wallet addressuint256Total contract count
listAllWhitelistedContractByClientReturns all whitelisted contract addresses_clientAddress Whitelisted wallet addressaddress[]Array of contract addresses
getSubscriptionInfoByClientReturns subscription details_clientAddress Whitelisted wallet addressuint64, boolSubscription 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 on