Guides

VRF for NFT mints: request patterns, gas limits and costs

Quip Network
·4 min read

A VRF mint works in two transactions: the mint call sends a randomness request to an oracle, and the oracle later calls the contract back with a random number and a proof, which the contract uses to assign the token's ID or traits. The hard choices are how many requests to make for a collection and how much work the callback can do inside its gas limit.

The request and callback flow

Ronin's VRF docs walk through the usual flow in a sample NFT contract:

  1. A buyer calls requestMintRandom(). The contract rejects a second request from the same address, sends a request to the coordinator, and records which buyer each request hash belongs to.
  2. The coordinator calls _fulfillRandomSeed with the random seed. The contract looks up the buyer from the request hash and mints a token using the seed as its ID.

The buyer has paid at step 1 but has no token until step 2. Chainlink VRF v2.5 waits a minimum number of block confirmations before it responds, set per network (1 on Arbitrum, 3 on BNB Chain) with a maximum of 200, according to its supported networks table. Contracts pick the number with the requestConfirmations parameter.

Rules for the contract

Chainlink's VRF security page lists the mistakes that let someone influence a result. These apply to mints:

  • Match each callback to its request. Store the requestId with the buyer's address, so the callback credits the right person.
  • Freeze inputs after the request. The contract should accept nothing from the buyer between the request and the callback that could change the outcome.
  • Never re-request or cancel. A contract allowing a new draw after a bad result gives the caller a reroll.
  • Keep the callback from reverting. Chainlink does not retry a reverted fulfillRandomWords(), so a revert leaves the buyer with a paid mint and no traits.

The Ronin sample re-requests when the seed matches a token ID already in use. When the full seed serves as the ID, a collision is extremely unlikely, but a contract drawing IDs from a small range would hit this branch often, and Chainlink's guidance treats any re-request as incorrect use for its own service.

The callback gas budget

On Arbitrum, Avalanche, Base and BNB Chain, Chainlink VRF v2.5 caps the callback at 2,500,000 gas and a single request at 500 random values (supported networks). Writing a value into an empty storage slot costs 20,000 gas under EIP-2200, plus 2,100 for a first access to that slot under EIP-2929, so 22,100 gas per new slot.

2,500,000 / 22,100 = 113.1

A single callback can therefore fill at most 113 fresh storage slots, before counting any other logic in the function. A request for 500 values, followed by a callback storing a trait record for each of 500 tokens, would run out of gas and revert, and the security rules above say a reverted callback is lost.

A cheaper callback stores the seed alone. The contract writes the seed into a single slot for 22,100 gas, and a view function derives each token's traits later, for example by hashing the seed together with the token ID. Anyone can recompute the result from the stored seed.

Request patterns for a 10,000 token collection

Ronin's docs give a worked fee estimate: a 0.01 USD service charge in RON plus the oracle's gas, which comes to 0.0175 RON per request at 250,000 callback gas, a 22 gwei gas price and an example rate of 4 USD per RON (Ronin VRF). The table multiplies that example figure by the number of requests each pattern needs. Actual fees move with gas prices and the RON exchange rate.

Pattern Requests for 10,000 tokens Fee at Ronin's example inputs Wait for traits Main exposure
A request per mint 10,000 175 RON A few blocks after each mint Every callback has to succeed, since a revert leaves a paid mint unfilled
A request per batch of 500 mints 20 0.35 RON Until the batch fills Buyers early in a batch wait longest, and the callback has to store a seed rather than 500 records
A single seed after the sale (offset reveal) 1 0.0175 RON Until the sale ends The team chooses when to request, so the art order needs a hash published before the sale

A request per mint gives each buyer a result tied to their own transaction. A single seed costs the least but moves the trust question to the reveal step, which the reveal guide covers in detail. For a comparison of block hashes, commit-reveal and oracles as randomness sources, read on-chain randomness methods.

Quantum randomness for mints

QVRF, Quip Network's randomness service, follows the same request-and-callback pattern, with values coming from measurements on a quantum computer (QVRF docs). Quip's Quantum Echoes collection uses the request-per-mint pattern: each mint requests a seed from the QVRF coordinator, and the token's traits come from the returned value.

Despite the name, QVRF is not a VRF in the cryptographic sense, as the docs point out. It is a physical randomness source with a verification record, and its output comes from a measurement rather than from a key.

Teams planning a QVRF mint should account for its current limits, all stated in the QVRF docs and on the QVRF page:

  • Quip runs the service. Quip operates both the oracle and the trustee, and splitting those roles is listed as the next step.
  • Delivery is operator-trusted. A commitment to the generated values goes on-chain before any value is handed out, so the operator can withhold a value but cannot swap it without detection.
  • Verification runs off-chain, after delivery. The audit record catches up later, and on-chain verification contracts are in development.
  • The interface is not final. Function names, parameters and the fee model are still being set, and integration docs with code examples will follow.

Next step

To request quantum randomness for a collection, start at quip.network/qvrf, and read the QVRF concepts page for the trust model.

Share
Filed underGuides
Newsletter

Don't miss an update

Get new posts and project updates delivered to your inbox. No spam, unsubscribe anytime.