
Genie Markets
Genie Markets is a house-funded, $USDC-denominated number prediction market.
Demo
About
Genie Markets is a house-funded, $USDC-denominated number prediction market where users wager on digit outcomes derived from Chainlink VRF v2.5 randomness. The protocol eliminates traditional Web3 friction via Privy with gas-sponsored transactions and allows users to sign in with a Google account or email, creating a seamless Web2-like experience for non-native crypto users. When signing in, users have to choose either a Google account/email or an external wallet. The difference is that signing in via external wallets (e.g., MetaMask) will require users to pay their own gas fees. After users deposit $USDC funds, they can participate in five prediction types across two daily market windows: *Market Windows: 1. Open Market: The open market window runs for 18 hours, allowing users to wager on Open Single, Pair, and Open Trio. 2. Close Market: The close market window runs for 6 hours. Users can wager on Close Single and Close Trio during the Open market window, but the window to wager on Open Single, Open Trio, and Pair officially closes at the end of the Open market window and the start of the Close market window. - Why open and close market? The open and close market allows for fun game types like the Pair. - The whole market runs for 24 hours (Open 18 hours + Close 6 hours). The market windows can be adjusted according to user preference. *Prediction Types: 1. Single Digits (0–9): Derived via (digit1 + digit2 + digit3) mod 10 for a 9x payout. E.g., 1, 2, 3 = Single 6 ((1+2+3) % 10 = 6) Single digits are of two types: Open Single and Close Single. Single digits are derived from Trios. (123 in the above example is a trio; more on this below). 2. Two Digit Pairs (00–99): Formed by combining the Open Single and Close Single outcomes for a 90x payout. E.g., 1, 2, 3 = Open Single 6 ((1+2+3) % 10 = 6) 4, 5, 6 = Close Single 5 ((4+5+6) % 10 = 5) The Pair becomes 65 (Open Single 6 & Close Single 5). 3. Three Digit Trios (000–999): High-tier jackpot markets sorted canonically under Genie Ordering math (1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 < 0). While there are 1,000 raw permutations from 000 to 999, enforcing canonical sorting reduces the pool to exactly 220 unique trio combinations. These offer tiered returns across three categories: - Unique Trio (3 distinct digits, e.g., 123): 140x - Twin Trio (2 identical digits, e.g., 100): 280x - Jackpot Trio (3 identical digits, e.g., 000): 600x There are only 10 Jackpot trios, 90 Twin Trios, and 120 Unique trios adding to 220 unique trios out of three digit trios from 000-999. Trios are of two types: Open Trio and Close Trio. The Open Single and Close Single are derived from the Open Trio and Close Trio. - Hence, the five prediction types are: Open Single, Close Single, Open Trio, Close Trio, and Pair. *Genie Market Round Flow 1. Users wager on singles, trios, and pairs. 2. First, the Open market is settled by Chainlink VRF. It returns a 3-digit number (e.g., 123)—this is the Open Trio. Based on this, the Open Single is derived (e.g., 6 in this case). In this step, the Open Single and Open Trio are settled. 3. Secondly, the Close market is settled as well by Chainlink VRF. It returns another 3-digit number (e.g., 456)—this is the Close Trio. Based on this, the Close Single is derived (e.g., 5 in this case). In this step, the Close Trio and Close Single are settled, along with the Pair (derived from Open Single + Close Single, e.g., 65). - The round settles as follows: Open Trio 123, Open Single 6, Close Trio 456, Close Single 5, and Pair 65. *All wagers are locked in a non-custodial smart contract escrow. Payouts are pull-based and can be claimed within 30 days of round finalization. If a randomness request hangs past a 24-hour window, a permission less emergency recovery mechanism allows any user to trigger 100% wager refunds.
How it's made
Genie Markets is built with a modern Web3 stack combining Solidity smart contracts, Chainlink VRF, Privy for gas sponsored transactions and sign in via google/email, and a Next.js prediction terminal. *Smart Contracts (Solidity + Foundry): - The core protocol lives in two contracts; 1. "GenieMarkets.sol" is a a 5-phase round state machine (Open Betting → Open Pending → Close Betting → Close Pending → Settled) that handles betting, Chainlink VRF draw requests, settlement, claims, refunds, and bankroll management. - All $USDC interactions use Open Zeppelin's "SafeERC20" and external transfers are guarded by "ReentrancyGuard". - Winners pull their own payouts via "claimWinnings()" with in 30 rounds of round settlement. 2. "GenieMath.sol" is a pure library that implements the custom Genie ordering math (`1 < 2 < ... < 9 < 0`), canonical trio sorting, single digit derivation via modular arithmetic, and trio type classification (Unique/Twin/Jackpot). *Frontend (Next.js + React): - The frontend uses Next.js App Router with wagmi and viem for all smart contract reads and writes. Custom React hooks encapsulate contract interaction logic. The UI is built with Tailwind CSS, shadcn/ui components, and Lucide React icons. *Chainlink VRF: - Each round makes two VRF calls; one for the Open draw, one for the Close draw. The contract extends VRFConsumerBaseV2Plus and uses VRFV2PlusClient to request randomness with 3 block confirmations. A 24-hour staleness check lets anyone call cancelStaleRound() to refund players if VRF never responds. *Privy (Embedded Wallets + ERC-4337 Gas Sponsorship): - This was the key integration for UX. Privy creates embedded smart accounts for users who sign in with Google or email; no MetaMask, no seed phrases. All transaction gas is sponsored through a custom use-smart-transaction hook that detects embedded vs. external wallets and routes transactions accordingly. Privy is wired into 14 components/hooks across the frontend for auth gating, wallet detection, and funding flows. External wallet users (MetaMask, etc.) are also supported but pay their own gas. *Partner technologies; Chainlink helped with VRF and Privy helped with UX.