🧠 How Randomness & Smart Contracts Power BaseWin
At the core of BaseWin lies a robust, secure, and fully decentralized architecture powered by two smart contracts:
Game Contract – manages ticket purchases, draws, and payouts.
Randomness Contract (via Pyth Entropy) – responsible for generating cryptographically secure, verifiable random numbers.
This design ensures that every lottery draw is both fair and tamper-proof. Here’s a detailed breakdown of how it works step by step:
Step-by-Step Flow of a Draw
1. Player initiates a bet
When a player buys a ticket, they interact directly with the Game Contract on-chain. This interaction includes sending USDC and triggering a function call to participate in the current lottery round.
2. Game Contract requests randomness
The Game Contract sends a request to the Pyth Entropy oracle — a trusted randomness provider integrated directly into the blockchain — to generate a secure random number.
3. Pyth Entropy generates a random number using dual-seed cryptography
To ensure true unpredictability, Pyth Entropy uses two distinct seed inputs:
Seed A (Client-side): Generated by the BaseWin platform for each round.
Seed B (Oracle-side): Independently provided by Pyth’s randomness infrastructure.
Both seeds are never revealed in advance and are combined using a cryptographically secure algorithm.
4. Seeds are cryptographically combined to produce a final number
These two seed values are merged in a way that ensures:
No party — not the user, not BaseWin, not even Pyth — can predict or manipulate the final number.
The output is unique for every request and cannot be reverse-engineered.
5. Pyth Entropy signs and returns the result
The final random number is digitally signed by the oracle and returned to the Game Contract. This signature ensures authenticity and integrity — only valid responses from the oracle will be accepted.
6. Game Contract calculates the winner
Using the returned random number, the Game Contract performs an on-chain calculation to determine the winning ticket:
This ensures that the result is deterministically tied to the number of tickets in the round.
7. Winnings are automatically transferred to the winner
If your ticket matches the winning index, the Game Contract immediately transfers the prize pool (stored in USDC) to your wallet. No intermediaries, no delays, no trust required.
Last updated

