How It Works
On this page (10 sections)
QanVault is an autonomous, provably fair Web3 prize protocol built on BNB Smart Chain. By combining O(1) batch storage architecture with Chainlink VRF v2.5 verifiable randomness and segregated mathematical reserves, QanVault delivers seamless multi-tier vaults with zero custodial risk.
Stage 1: Direct QANX Ticket Purchase
Players approve and pay the configured QANX token on the configured settlement chain. Verify ticketPrice on the deployed vault.
Stage 2: Deterministic Escrow Allocation
Upon receipt, the smart contract immediately and deterministically partitions the 100 QANX per ticket across 5 segregated accounting reserves.
Stage 3: Provably Fair Draw Execution
Anyone may close an ended period and settle after the original Chainlink VRF request fulfills. Transaction execution is required.
Stage 4: Canonical Prize Claim & Settlement
Prizes are paid in the configured QANX token on the settlement chain. Gas, confirmation and token transfer availability are required.
1. Direct QANX Ticket Purchase#
Every entry starts by purchasing tickets directly through the smart contract on the configured settlement chain (BNB Smart Chain).
Daily Draw (D)
First chance to win on the date of purchase
Weekly Vault (W)
Enters the week-long cumulative vault pool
Monthly Grand (M)
Enters the massive monthly community pot
Seed Reserve Architecture (30%): An additional 30% of sales funds tomorrow's Daily Pot (D+1) starting seed reserve. Tickets purchased today participate strictly in today's Daily draw (D) and do not roll over to future daily draws.
Key Purchase Mechanics
- Settlement Token: Purchases are denominated in the canonical BEP-20 / ERC-20
QANXtoken. - Fixed Ticket Price: Each ticket is priced at exactly 100 QANX (
ticketPrice()). - High-Throughput Batching: Purchase up to 10,000 tickets in a single transaction. The contract records entries in O(1) constant time via
TicketBatchcontiguous ranges, keeping network gas negligible (~1-3 Gwei / ~$0.02 - $0.05). - No Daily Wallet Limits: There is no daily or lifetime cap per wallet. Participants can acquire additional batches at any time while the draw window is active.
- On-Chain Proof: Confirmed blockchain receipts emit the
TicketsPurchasedevent containing your starting ticket ID, count, and period IDs.
2. Deterministic 5-Way Reserve Allocation#
When a ticket is purchased for 100 QANX, the funds never pool into an opaque company wallet. Instead, the smart contract immediately and deterministically partitions the 100 QANX across 5 segregated accounting reserves (10,000 basis points total):
Allocation Example: 100 QANX Paid Ticket
10,000 Basis Points Total Allocation
| Allocation Bucket | Share | Amount per Ticket | Purpose & Timing |
|---|---|---|---|
| Active Daily Vault (D) | 50.0% | 50.0 QANX | Funds today's active daily vault pool closing at 00:00:00 UTC |
| Next-Day Seed Reserve (D+1) | 30.0% | 30.0 QANX | Seeds tomorrow's initial daily vault pool so every day starts funded |
| Weekly Vault (W) | 7.5% | 7.5 QANX | Accumulates across the ISO calendar week, drawing Monday at 00:00:00 UTC |
| Monthly Vault (M) | 5.0% | 5.0 QANX | Accumulates across the calendar month, drawing on the 1st at 00:00:00 UTC |
| Protocol Treasury | 7.5% | 7.5 QANX | Sustains decentralized infrastructure, keeper gas, and discretionary ecosystem growth or marketing, with no guaranteed schedule or expectation of return |
3. Draw Period Closure & VRF Request#
Draws operate on strict, immutable UTC time boundaries:
- Daily Draws: Close every night at 23:59:59 UTC.
- Weekly Draws: Close every Sunday night at 23:59:59 UTC (Monday 00:00:00 UTC).
- Monthly Draws: Close on the final second of each calendar month.
Tickets can be purchased; range records increment sequentially until 23:59:59 UTC cutoff.
Anyone closes an ended nonempty draw. Its pool and eligible count are fixed with one VRF request.
After original coordinator fulfillment, anyone can settle. No retry or cancellation exists; outages can lock the pool indefinitely.
Winning wallets claim before 72 hours from settlement. Expiry processing assigns 7.5% to Protocol Treasury and reserves the remainder for the following day.
The Randomness Lifecycle
Permissionless Closure: Once a period's timestamp has elapsed, any participant or keeper bot can call
closeDraw(drawType, periodId).Freezing the Pool: Closure freezes the draw's vault pool and eligible ticket count. All subsequent ticket purchases automatically enter the next active period.
Chainlink VRF v2.5 Dispatch: For nonempty draws, the contract requests provably fair randomness from the immutable
ChainlinkVRFProvidercoordinator.Empty Draw Optimization: If zero tickets were purchased during a period, the contract skips the paid VRF oracle call and automatically rolls 100% of the vault pool into the future daily reserve.
4. Cryptographic Settlement & Sparse Fisher-Yates Sampling#
Once the Chainlink VRF Coordinator fulfills the randomness request with a cryptographically verified seed, the draw can be settled via settleDraw(drawId).
Winning Ticket Selection Algorithm
- Distinct Winning Indices: The contract executes a sparse Fisher-Yates shuffle using
keccak256(abi.encode(seed, slotIndex))to select winning ticket indices without replacement. - Multi-Ticket Fairness: Draws select distinct ticket IDs, not wallet addresses. If a participant owns multiple tickets in the eligible range, each ticket has an independent chance of winning. Once a ticket wins any prize tier, it is retired from future draws; wallets with multiple tickets may win multiple prizes across draws if separate tickets are drawn.
- $O(\log B)$ Binary Search Resolution: The contract resolves the winning wallet address by performing a binary search (
getBatchForTicket) across theticketBatchesarray in logarithmic time, keeping settlement gas strictly bounded.
Vault Tier Distribution
- Daily Draw (Up to 10 Winning Tickets):
- Tier 1: Grand Prize (1 winning ticket) takes 70% of the vault pool + all rounding dust.
- Tier 2 (up to 3 winning tickets) takes 5% each (15% total).
- Tier 3 (up to 6 winning tickets) takes 2.5% each (15% total).
- Weekly Draw (Up to 3 Winning Tickets): Grand Prize (70%), 1st Runner-Up (20%), 2nd Runner-Up (10%).
- Monthly Draw (1 Winning Ticket): 100% Vault Share Single Winning Ticket.
5. Non-Custodial Claims & 72-Hour Community Rollover#
When a draw settles, winning funds are immediately credited to totalClaimLiabilities on-chain.
Draw Finalized
Closure is allowed after the UTC period ends. Settlement requires original VRF fulfillment and a separate transaction; its time is not guaranteed.
Active Winning Wallet Claim
Winning wallet calls claimPrize(drawId, winnerIndex) on the configured chain before the 72-hour deadline. A successful transaction transfers QANX.
Expiry Can Be Processed
At 72 hours, anyone may process expiry. 7.5% becomes protocol treasury fees; the remainder seeds the daily reserve for the day after processing.
Claiming Rules
- 72-Hour Claim Window: Winning wallets have exactly 72 hours (259,200 seconds) from the settlement timestamp to withdraw their prizes by calling
claimPrize(drawId, winnerIndex). - Direct Wallet Payout: Funds are transferred directly to the winning wallet in canonical QANX tokens.
- Community Rollover: If a prize remains unclaimed after 72 hours, anyone can call
expireAndRollover(drawId, winnerIndex). 7.5% is allocated to the protocol treasury, and the remaining 92.5% is rolled into the future daily prize reserve to enrich upcoming community draws.