Skip to content

robertointech/lucky-goal-mvp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

38 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Lucky Goal

Multiplayer trivia + penalty kicks game on Avalanche. Host tournaments on a big screen while players compete from their phones β€” Kahoot-style with Web3 prizes.

Built for B2B events, conferences, and watch parties. The host projects the game; players join with a PIN code and compete for AVAX prizes.

Lucky Goal Banner

How It Works

  1. Host creates a tournament on desktop/projector, deposits AVAX as prize
  2. Players scan QR / enter PIN on their phones to join the lobby
  3. 5 trivia rounds β€” each with a question + penalty kick shootout
  4. Winner claims the prize via Passkey wallet (no seed phrase needed)

Screenshots

Host Lobby Player Game Claim Prize
lobby game claim

Replace with actual screenshots

Tech Stack

Layer Technology
Frontend Next.js 16, React 18, TypeScript
Styling Tailwind CSS, CSS animations
3D React Three Fiber (penalty kicks)
Realtime Supabase Realtime (game sync)
Database Supabase (PostgreSQL)
Blockchain Avalanche C-Chain (Fuji testnet)
Wallets Thirdweb SDK + Passkey wallets
Smart Contract Solidity 0.8.20 (Hardhat)

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     Supabase Realtime     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   HOST (desktop) │◄────────────────────────►│  PLAYERS (mobile) β”‚
β”‚   /host/*        β”‚     status updates        β”‚  /play/*          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                           β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                                              β”‚
         β”‚  Thirdweb SDK                                β”‚  Passkey wallet
         β–Ό                                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Avalanche Fuji Testnet                        β”‚
β”‚           LuckyGoalEscrow (prize deposit + claim)               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Game flow: Host controls all phase transitions (question β†’ penalty β†’ results) via Supabase status updates. Players react in real-time. Answer evaluation is local for instant feedback; scores are submitted to the DB.

Penalty logic: Wrong trivia answer = 0% goal chance. Correct answer = random goalkeeper direction + 30% save chance if same direction picked.

Smart Contract

LuckyGoalEscrow β€” deployed on Avalanche Fuji testnet

Address 0xd638D0f20B3b7a6FDaf6eba5753b05Ad1695012F
Network Avalanche Fuji (Chain ID 43113)
Solidity 0.8.20
Source src/contracts/LuckyGoalEscrow.sol

Functions:

  • createTournament(code) β€” payable, deposits AVAX prize
  • claimPrize(code, winner) β€” transfers prize to winner's wallet
  • getTournament(code) β€” view tournament state

Getting Started

Prerequisites

  • Node.js 18+
  • npm

Environment Variables

Create .env.local:

NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
NEXT_PUBLIC_THIRDWEB_CLIENT_ID=your_thirdweb_client_id
NEXT_PUBLIC_ESCROW_CONTRACT=0xd638D0f20B3b7a6FDaf6eba5753b05Ad1695012F
DEPLOYER_PRIVATE_KEY=your_deployer_key  # only for contract deployment

Install & Run

npm install --legacy-peer-deps
npm run dev

Open http://localhost:3000

--legacy-peer-deps is required because React Three Fiber v9 expects React 19, but the project uses React 18.

Test on Mobile

  1. Find your local IP: ipconfig getifaddr en0 (Mac)
  2. Open on phone: http://YOUR_IP:3000
  3. Both devices must be on same WiFi

Deploy Contract (optional)

npx hardhat run scripts/deploy.ts --network fuji

Project Structure

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ host/              # Host screens (desktop/projector)
β”‚   β”‚   β”œβ”€β”€ page.tsx       # Create tournament
β”‚   β”‚   β”œβ”€β”€ lobby/[code]/  # QR + waiting room
β”‚   β”‚   └── game/[code]/   # Game flow (projector view)
β”‚   β”œβ”€β”€ play/              # Player screens (mobile)
β”‚   β”‚   β”œβ”€β”€ page.tsx       # Enter PIN
β”‚   β”‚   β”œβ”€β”€ join/[code]/   # Choose avatar + nickname
β”‚   β”‚   β”œβ”€β”€ lobby/[code]/  # Waiting room
β”‚   β”‚   └── game/[code]/   # Game flow (mobile view)
β”‚   └── claim/[code]/      # Winner claims prize
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ gameLogic.ts       # Supabase CRUD operations
β”‚   β”œβ”€β”€ escrow.ts          # Thirdweb contract helpers
β”‚   β”œβ”€β”€ questions.ts       # 20 trivia questions
β”‚   └── thirdweb.ts        # Thirdweb client config
β”œβ”€β”€ hooks/
β”‚   β”œβ”€β”€ useGameSync.ts     # Supabase Realtime subscription
β”‚   └── useCountdown.ts    # Timer hook
β”œβ”€β”€ components/
β”‚   └── PenaltyScene.tsx   # React Three Fiber 3D scene
β”œβ”€β”€ contracts/
β”‚   └── LuckyGoalEscrow.sol
└── types/
    └── game.ts            # TypeScript interfaces

Demo

Watch the demo video

License

MIT

About

🎯 Lucky Goal - B2B gamified trivia + penalty kicks on Avalanche. Sponsors create tournaments, players compete for crypto prizes using Passkey wallets. Built for Avalanche Builders 2026.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages