Skip to Content

Gas Configurations

Now that you understand how dVRF works and have created your subscription, it’s time to configure gas settings properly. Gas configuration is crucial because it determines both your callback performance and minimum balance requirements. Getting this right ensures reliable random number delivery while managing costs effectively.

Why Gas Configuration Matters

  • Performance: Higher gas settings = faster callback execution during network congestion
  • Cost Control: Optimized settings prevent overpaying while ensuring reliability
  • Minimum Balance: Your gas settings directly calculate the required minimum balance
  • Request Success: A callback is not sent when its fee exceeds the module’s max_callback_txn_fee

Supra L1 Transaction Fee Configuration

Supra dVRF on Supra L1 uses a simplified transaction fee model with configurations at two levels. Both are amounts in quants (1 SUPRA is 100,000,000 quants), the unit of every balance, grant and fee that the dVRF contracts return.

Wallet Level (Required)

Maximum Transaction Fee (max_txn_fee): The highest transaction fee you’ll pay for any callback across all your modules. This is set when whitelisting your wallet address, and it determines your minimum balance.

Module Level (Optional)

Maximum Callback Transaction Fee (max_callback_txn_fee): Transaction fee limit for a specific requester module (must be ≤ max_txn_fee).

dVRF sends the callback for a request only if its fee is within the requester module’s max_callback_txn_fee. When the callback would cost more, the request transaction still succeeds and emits RequestEventV2 with a nonce, but no callback is sent and the nonce stays unprocessed. Raising the limit afterwards does not send it; request again. A module’s max_callback_txn_fee of 0 means no limit for that module.

The callback fee depends on the callback’s execution. Read what a callback was charged from the FeesCollectedEvent (grant_amount plus client_amount) of its NonceProcessedEvent transaction, and set the limit above it:

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

get_module_info returns the module’s max_callback_txn_fee, enabled flag, the min_balance_limit and the client’s balance and current_grant. <VRF_ADDRESS> is the dVRF address of your network in Available Networks.

Setting Transaction Fees

You are prompted to set these values at the subscription creation stage in the subscription manager UI, and you can modify them later from the menu. You can also do the same via onchain functions.

Wallet level

deposit::whitelist_client_address(client: &signer, max_txn_fee: u64) deposit::update_max_txn_fee(user: &signer, max_txn_fee: u64)
# Whitelist the wallet with a max transaction fee, in quants supra move tool run \ --function-id <VRF_ADDRESS>::deposit::whitelist_client_address \ --args u64:<MAX_TXN_FEE> # Change it later supra move tool run \ --function-id <VRF_ADDRESS>::deposit::update_max_txn_fee \ --args u64:<MAX_TXN_FEE>

update_max_txn_fee recalculates the minimum balance. It lowers the limit of any module whose max_callback_txn_fee is above the new value, and never raises a module limit. It aborts with ESTATE_UNCHANGED when the value equals the current one.

Module Level

For granular control, set different fee limits for specific modules:

deposit::update_max_callback_txn_fee<T>(client: &signer, max_callback_txn_fee: u64)
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>

A module’s limit starts at the wallet’s max_txn_fee of the moment the module is registered (init_vrf_module). A value above the wallet’s max_txn_fee is not applied, although the transaction succeeds; read the limit back with get_module_info to confirm the change.

Optimising After Testing

After testing, lower the limits if the callback’s actual fee is below them. Keep each limit above the largest callback fee you have read from FeesCollectedEvent.

Minimum Balance

The contracts compute the minimum balance from your wallet’s max_txn_fee:

Minimum Balance = max_txn_fee × min_request_count

When max_txn_fee is 0, the minimum balance is instead the contract-wide min_balance_limit_supra, which Supra sets.

Where:

  • min_request_count = The number of requests Supra requires you to be able to afford. Read it with deposit::min_request_count; the value can change.
supra move tool view --function-id <VRF_ADDRESS>::deposit::min_request_count

The minimum balance is compared with your balances in three places:

  • Request. supra_vrf::rng_request_v2 aborts with EMIN_BALANCE_REACHED when your remaining grant plus your deposited funds is at or below the minimum balance. deposit::has_minimum_balance_reached_v2 returns true in the same case.
  • Deposit. deposit_fund_v2 aborts with EMIN_BALANCE unless the deposited funds after the deposit are above the minimum balance.
  • Effective balance. deposit::check_effective_balance_v2 returns the deposited funds minus the minimum balance, or 0 when the funds are not above it. Grants are not counted.

Raising max_txn_fee raises the minimum balance, so the next deposit must bring the deposited funds above the new minimum. A request can be served while the effective balance is 0, as long as the remaining grant plus the deposited funds is above the minimum balance.

Monitoring Your Funds

Supra doesn’t send automated email alerts and users are advised to implement their own balance monitoring.

  • 300% of minimum balance: Plan your next deposit
  • 200% of minimum balance: Schedule deposit soon
  • 100% of minimum balance: Urgent - when grant plus deposit reaches the minimum balance, new requests abort
  • At minimum balance: Critical - immediate deposit required

Here’s an example structure for monitoring. check_effective_balance_v2 and has_minimum_balance_reached_v2 are not declared by the vrf-interface package, so the example computes the same values from the functions it declares:

#[view] public fun get_subscription_health(client_address: address): (u64, u64, u64, bool) { let total = deposit::check_client_fund(client_address); let minimum = deposit::check_min_balance_client_v2(client_address); let grant = deposit::get_client_remaining_grant(client_address); let effective = if (total > minimum) total - minimum else 0; let at_minimum = grant + total <= minimum; (total, minimum, effective, at_minimum) }

Dev tips for better experience

  • Start Conservative: Begin with higher limits, optimize down over time
  • Test Thoroughly: Always test your callback gas usage before production
  • Monitor Actively: Set up alerts for deposit balance warnings at matching threshold levels via UI
  • Update Regularly: Adjust settings based on network conditions and usage patterns
  • Plan for Peaks: Account for network congestion during high-demand periods
Last updated on