โ ๏ธ DEVELOPMENT STATUS: MVP IN PROGRESS This is an early-stage MVP under active development. Backend functionality is currently being built. The smart contract is deployed on Arbitrum Sepolia testnet.
A blockchain-based multiplayer trivia game built on Arbitrum Stylus, leveraging Web3 technologies for real-time, trustless gaming experiences.
- About
- Features
- Tech Stack
- Prerequisites
- Getting Started
- Environment Setup
- Smart Contract
- Project Structure
- Game Flow
- Development Roadmap
- Contributing
TriviaChain is a decentralized trivia game where players can create or join game sessions, compete in real-time, and have their scores recorded on-chain. The game leverages Arbitrum Stylus smart contracts written in Rust for efficient, low-cost blockchain interactions.
- โ Wallet Connection: Connect with MetaMask, Rainbow, and other Web3 wallets via RainbowKit
- โ Create Game Sessions: Host games with customizable settings (max players, question count, difficulty)
- โ Join Game Sessions: Join games using unique room codes
- โ Game Lobby: Real-time player tracking before game starts
- โ Multiple Question Categories: Tech, General Knowledge, and Party questions
- โ Difficulty Levels: Easy, Medium, and Hard questions with varying time limits
- โ On-chain Score Recording: Player scores stored on Arbitrum blockchain
- โ Winner Determination: Smart contract determines and records winners
- ๐ Backend Integration: Real-time game synchronization
- ๐ Leaderboards: Global and session-based rankings
- ๐ NFT Rewards: Winner badges and achievements as NFTs
- ๐ Custom Question Pools: Allow users to create custom trivia sets
- ๐ Spectator Mode: Watch ongoing games
- ๐ Tournament Mode: Multi-round elimination tournaments
- React 19 - UI framework
- TypeScript - Type safety
- Vite - Build tool and dev server
- TailwindCSS - Styling
- Wagmi - Ethereum interactions
- Viem - Ethereum utilities
- RainbowKit - Wallet connection UI
- React Hot Toast - Notifications
- Arbitrum Stylus - Layer 2 smart contract platform
- Rust - Smart contract language (backend contract)
- Arbitrum Sepolia - Testnet deployment
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher)
- npm or yarn or pnpm
- Git
- MetaMask or another Web3 wallet browser extension
git clone <repository-url>
cd trivia-app/Frontend
npm install
# or
yarn install
# or
pnpm install
Create a .env
file in the root directory:
cp .env.example .env
Edit .env
with your configuration:
VITE_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_id
VITE_TRIVIA_CONTRACT_ADDRESS=0xb619a20ace8e373752c960347f96805434129e89
Get your WalletConnect Project ID:
- Go to WalletConnect Cloud
- Create a new project
- Copy your Project ID
Network Details:
- Network Name: Arbitrum Sepolia
- RPC URL:
https://sepolia-rollup.arbitrum.io/rpc
- Chain ID:
421614
- Currency Symbol:
ETH
- Block Explorer:
https://sepolia.arbiscan.io/
Get Testnet ETH:
- Use Arbitrum Sepolia Faucet
- Or bridge from Sepolia ETH via Arbitrum Bridge
npm run dev
The app will be available at http://localhost:5173
npm run build
Preview production build:
npm run preview
Variable | Description | Required |
---|---|---|
VITE_WALLETCONNECT_PROJECT_ID |
WalletConnect Cloud project ID | Yes |
VITE_TRIVIA_CONTRACT_ADDRESS |
Deployed smart contract address | Yes |
The app is configured to work with Arbitrum Sepolia testnet. Configuration can be found in src/wagmi.ts
.
- Address:
0xb619a20ace8e373752c960347f96805434129e89
- Network: Arbitrum Sepolia
- Language: Rust (Stylus)
- Block Explorer: View on Arbiscan
// Create a new game session
createSession(room_code: bytes32, max_players: uint256, question_duration: uint256) -> uint256
// Join an existing session
joinSession(session_id: uint256, room_code: bytes32, display_name: bytes32)
// Start the game (host only)
startSession(session_id: uint256)
// Submit an answer
submitAnswer(session_id: uint256, question_index: uint256, answer_hash: bytes32, correct_answer_hash: bytes32, difficulty: uint8) -> uint256
// End game and determine winner
endSession(session_id: uint256) -> address
// Get winner address
getWinner(session_id: uint256) -> address
// Get player score
getPlayerScore(session_id: uint256, player: address) -> uint256
SessionCreated
- Emitted when a new game is createdPlayerJoined
- Emitted when a player joinsSessionStarted
- Emitted when host starts the gameAnswerSubmitted
- Emitted when a player submits an answerSessionEnded
- Emitted when game ends with winner info
Frontend/
โโโ src/
โ โโโ components/ # React components
โ โ โโโ HomePage.tsx # Landing page with wallet connection
โ โ โโโ HostGame.tsx # Create game interface
โ โ โโโ JoinGame.tsx # Join game interface
โ โ โโโ GameLobby.tsx # Pre-game lobby
โ โ โโโ GamePlay.tsx # Main game interface
โ โ โโโ GameResults.tsx # Post-game results
โ โโโ contracts/
โ โ โโโ TriviaChain.ts # Contract ABI and address
โ โโโ data/
โ โ โโโ questions.ts # Question pool
โ โโโ types/
โ โ โโโ index.ts # TypeScript types
โ โโโ App.tsx # Main app component
โ โโโ main.tsx # App entry point
โ โโโ wagmi.ts # Wagmi configuration
โ โโโ index.css # Global styles
โโโ public/ # Static assets
โโโ .env.example # Environment template
โโโ package.json # Dependencies
โโโ vite.config.ts # Vite configuration
โโโ tailwind.config.js # Tailwind configuration
โโโ tsconfig.json # TypeScript configuration
- User connects Web3 wallet via RainbowKit
- Supports MetaMask, Rainbow, WalletConnect, and more
Host:
- Set max players (2-10)
- Choose question count (5-20)
- Select difficulty (Easy/Medium/Hard/Mixed)
- Choose category (Tech/General/Party/Mixed)
- Receive unique 6-character room code
Join:
- Enter 6-character room code
- Provide display name
- Wait for players to join
- Host can see all connected players
- Host starts game when ready
- Questions displayed one at a time
- Time-limited answers (15-30s based on difficulty)
- Points awarded based on:
- Correctness
- Speed of answer
- Question difficulty
- Progress tracked on-chain
- Winner determined by smart contract
- Final scores displayed
- Option to play again
- Frontend UI/UX
- Wallet integration
- Smart contract integration
- Basic game flow
- Question system
- WebSocket server for real-time sync
- Backend API for game state management
- Database for game history
- Improved player synchronization
- Leaderboards and statistics
- NFT reward system
- Custom question pools
- Tournament mode
- Spectator mode
- Social features (friend challenges, chat)
- Performance optimization
- Multi-chain support
- Mobile app (React Native)
- Advanced analytics
- Community governance
Contributions are welcome! This is an active development project.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Use TypeScript for type safety
- Follow React best practices
- Use Tailwind CSS for styling
- Write meaningful commit messages
- Comment complex logic
- Backend synchronization not implemented (frontend-only MVP)
- Real-time player updates rely on blockchain events (may have delays)
- Question pool is limited (hardcoded)
- No persistence of game history
This project is part of the Web3Bridge Rust Masterclass program.
For questions or issues, please open an issue in the repository.
Built with โค๏ธ for Web3Bridge Rust Masterclass