Launch App
Play & Draw Rules

Provably Fair Randomness

The request lifecycle#

Draw operations are automated by the protocol's continuous 24/7 background keeper daemons as soon as each UTC period ends. In addition, the smart contract's closeDraw function is permissionless: anyone can close a daily, weekly, or monthly draw after its UTC period has ended. This decentralization guarantee ensures draws are never dependent on any single operator or server. closeDraw records the eligible ticket count and vault pool before making a request. An empty draw settles without purchasing randomness; its full pool is assigned to a future daily reserve. A nonempty draw receives one request ID from the vault's configured provider and remains pending until that specific request is fulfilled.

The release's Chainlink VRF v2.5 adapter fixes the coordinator address, gas lane, subscription ID, and native-versus-LINK billing at deployment. The subscription must authorize the adapter as a consumer and have enough of the selected payment currency. A request ID proves only request acceptance. It does not prove that a VRF proof was delivered, that the callback succeeded, or that a draw settled. The adapter accepts a zero random word as a valid seed.

Selecting winning tickets#

After fulfillment, anyone may call settleDraw. The vault derives one index for each prize slot from keccak256(abi.encode(seed, slotIndex)) and uses a partial Fisher-Yates shuffle to select ticket IDs without replacement within that draw. It records each winning ticket, its owner, and its amount. A wallet with multiple eligible tickets may receive more than one prize in a draw. A single ticket cannot fill two slots in the same draw, but remains eligible in its other schedules.

This source uses Chainlink VRF rather than a keeper-held secret or commit-reveal scheme. The keeper can call public lifecycle functions but cannot supply a replacement seed. Timestamp-derived period membership is separate from the VRF seed; transactions close to a UTC boundary can enter different periods depending on inclusion time.

Rechecking a draw#

  1. Establish that the deployed vault and provider runtimes match the reviewed release. A matching UI address or explorer label is not enough.

  2. Read getDrawInfo(drawId) and confirm draw type, period ID, fixed eligible count and pool, request ID, settlement state, and seed.

  3. Match the provider's request and coordinator callback to that request ID. Check the target chain and approved coordinator.

  4. Inspect the period's TicketRange and each winning ticket's recorded owner. Recompute selection using the released algorithm if desired.

  5. Check getDrawWinningSlots(drawId) for amounts and prize status. Pool percentages and integer-rounding dust are described in Odds and Prize Tiers.

Local test harnesses simulate deterministic seeds during contract unit testing and do not reproduce Chainlink VRF cryptographic proof delivery. Production randomness fairness is guaranteed exclusively by on-chain Chainlink VRF v2.5 proofs on BNB Smart Chain.

When fulfillment is delayed#

retryRandomness and cancelTimedOutDraw always revert. The 24-hour timeout constant is an alert threshold, not permission to replace the request. This avoids a caller choosing between visible candidate outcomes. A nonempty pool may nevertheless stay locked indefinitely if the original oracle request never fulfills: there is no fallback seed, refund, rollover, or owner rescue. Oracle and block-producer withholding remain separate risks.

Smart Contract Immutability#

The QanVault protocol (QanVault.sol) deployed at 0x5ae863435F5aB9f8c06cE180ceb88E76751D9e25 on BNB Smart Chain is 100% immutable and non-upgradeable:

  1. No Proxy Architecture: The contract is deployed directly as concrete runtime bytecode. There are no ERC-1967, UUPS, Diamond, or Transparent upgradeability proxies. The deployed bytecode cannot be modified, patched, or replaced.

  2. Immutable Variables: Critical dependencies are declared immutable in Solidity:

  • IERC20 public immutable qanxToken;
  • IRandomnessProvider public immutable randomnessProvider;
  • uint32 public immutable firstDay;
  • uint32 public immutable firstWeek;
  • uint32 public immutable firstMonth;

These addresses and genesis periods are burned directly into the compiled runtime bytecode at deployment.

  1. Permanent Randomness Binding: The configuration function setRandomnessProvider(address) explicitly reverts with revert ImmutableRandomness(). Neither the contract owner nor platform operators can change the VRF coordinator or redirect entropy requests.

  2. Hardcoded Mathematical Constants: Allocation percentages (50% Daily, 30% Next Day, 7.5% Weekly, 5% Monthly, 7.5% Protocol Fee), the 72-hour claim window (CLAIM_WINDOW = 72 hours), and the 24-hour randomness timeout (RANDOMNESS_TIMEOUT = 24 hours) are compile-time Solidity constants.

  3. No Backdoor Fund Drains: The contract does not implement emergency withdrawal functions (emergencyWithdraw, rescueERC20, or selfdestruct). Vault prize pools, rollover reserves, and claim liabilities are non-custodial and untouchable. The owner can only withdraw segregated platform fees (withdrawPlatformFees) strictly up to accruedPlatformFees.