Skip to Content

Add Contracts to Subscription

After creating your subscription and configuring gas settings, you need to whitelist your consumer contracts. Only whitelisted contracts can request random numbers from your subscription.

Important: Make sure you’ve read the Gas Configuration page first. Understanding gas settings is crucial before adding contracts and funds, as your contract-level gas configuration directly impacts performance, costs, and minimum balance requirements


Via Onchain Contracts

Whitelisting Your Module

After deploying your requester module, whitelist it with Supra to enable VRF requests:

deposit::init_vrf_module<T>(client: &signer): SupraVRFPermit<T>

init_vrf_module is not an entry function, so it cannot be run on its own. Call it from your module’s init_module, which runs once when the package is published (see Request Random Numbers). Publishing is therefore the on-chain step that adds the contract:

supra move tool publish \ --package-dir <PACKAGE_DIR>

<PACKAGE_DIR> is your Move package, whose Move.toml maps your module’s address to your whitelisted wallet. The publish aborts if the wallet is not whitelisted first.

Parameters:

  • client - Your signer (must be the whitelisted wallet address)
  • T - Your module’s type/struct (e.g., YourModule)

Returns:

  • SupraVRFPermit<T> - A capability that authorizes your module to interact with Supra VRF

Important: Store the returned SupraVRFPermit<T> capability in your module. This permit is required for all VRF requests.

Check the registration: the module’s settings are readable with get_module_info. <VRF_ADDRESS> is the dVRF address of your network in Available Networks.

supra move tool view \ --function-id <VRF_ADDRESS>::deposit::get_module_info \ --type-args <CLIENT_ADDRESS>::<MODULE_NAME>::<MODULE_TYPE>

The result lists enabled and max_callback_txn_fee. The module starts with a max_callback_txn_fee equal to the wallet’s max_txn_fee at the time of registration. If a callback costs more than that limit it is not sent, so compare the limit with the fee of your callbacks as described in Gas Configurations, and change it with update_max_callback_txn_fee:

supra move tool run \ --function-id <VRF_ADDRESS>::deposit::update_max_callback_txn_fee \ --type-args <CLIENT_ADDRESS>::<MODULE_NAME>::<MODULE_TYPE> \ --args u64:<MAX_CALLBACK_TXN_FEE>

Disabling a Contract

Temporarily stop a module from making requests without removing it:

deposit::disable_module<T>(client: &signer)

Example:

// Temporarily disable the module deposit::disable_module<ClientExample>(&signer);

Re-enabling a Contract

Reactivate a previously disabled module:

deposit::enable_module<T>(client: &signer)

Best Practices

Store the Permit Safely: The SupraVRFPermit<T> capability is essential for making VRF requests. Store it in a resource with key ability.

One Permit Per Module: Each module type can only have one permit. Don’t try to create multiple permits for the same module.

Module-Specific Limits: Use per-module fee limits to isolate costs, especially for experimental features.

Troubleshooting

“Module disabled” error:

  • Check that you’re using the correct signer (whitelisted wallet)
  • Verify the SupraVRFPermit<T> is properly stored

“Insufficient permissions” error:

  • Ensure you called init_vrf_module<T>() after deploying your module
  • Verify your wallet was whitelisted first

“Module not whitelisted” error:

  • Ensure you called init_vrf_module<T>() after deploying your module
  • Verify your wallet was whitelisted first
Last updated on