A blockchain-based competitive word game built on React Native, Ethereum smart contracts, and The Graph protocol. Players compete in timed word chain races where the fastest solver wins the prize pool.
WordChain India is a decentralized gaming platform that combines:
- Real-time competitive gameplay - Players race to solve word chain puzzles
- Blockchain-based wagering - Entry fees create prize pools managed by smart contracts
- Automated game orchestration - Backend scheduler manages game sessions
- Decentralized data indexing - The Graph subgraph for efficient querying
- Framework: React Native with Expo
- Navigation: React Navigation (Stack + Bottom Tabs)
- Web3 Integration: ethers.js v6
- UI Components: Custom screens for Lobby, Game Arena, Leaderboard, Profile, and Wallet
- Server: Express.js
- Game Logic: Automated scheduler with cron jobs
- Blockchain Integration: ethers.js for smart contract interaction
- Dictionary Management: Word validation service
- WagerQuest.sol - Core game contract managing entry fees, scoring, and prize distribution
- QuestFactory.sol - Factory pattern for deploying new game instances
- RewardPool.sol - Prize pool management
- MockMONToken.sol - Test token for development
- Protocol: The Graph
- Schema: Game and Player entities
- Indexing: Real-time blockchain event tracking
wordChain/
├── App.js # Main app entry with navigation
├── index.js # Expo entry point
├── package.json # Root dependencies
│
├── screens/ # React Native screens
│ ├── LobbyScreen.js # Game listing & join
│ ├── GameArenaScreen.js # Active gameplay
│ ├── LeaderboardScreen.js # Rankings & stats
│ ├── ProfileScreen.js # User profile
│ └── WalletScreen.js # Web3 wallet integration
│
├── components/
│ └── ErrorBoundary.js # Error handling wrapper
│
├── services/
│ └── web3.js # Blockchain interaction layer
│
├── backend/ # Express server
│ ├── server.js # Server entry point
│ └── src/
│ ├── config.js # Environment configuration
│ ├── routes.js # API endpoints
│ ├── scheduler.js # Cron job management
│ ├── dictionary.js # Word validation
│ └── services/
│ ├── gamestate.js # Game session management
│ └── blockchain.js # Smart contract integration
│
├── contracts/ # Solidity smart contracts
│ ├── hardhat.config.js # Hardhat configuration
│ ├── contracts/
│ │ ├── WagerQuest.sol # Main game contract
│ │ ├── QuestFactory.sol # Game factory
│ │ ├── RewardPool.sol # Prize distribution
│ │ └── MockMONToken.sol # Test token
│ ├── scripts/
│ │ └── deploy.js # Deployment script
│ └── artifacts/ # Compiled contracts
│
└── subgraph/ # The Graph indexing
├── schema.graphql # GraphQL schema
├── subgraph.yaml # Subgraph manifest
├── src/
│ └── mapping.ts # Event handlers
└── generated/ # Auto-generated types
- Node.js (v16+)
- npm or yarn
- Expo CLI
- Hardhat (for smart contracts)
- MetaMask or compatible Web3 wallet
- Clone the repository
git clone <repository-url>
cd wordChain- Install root dependencies
npm install- Install backend dependencies
cd backend
npm install
cd ..- Install contract dependencies
cd contracts
npm install
cd ..- Install subgraph dependencies
cd subgraph
npm install
cd ..Create a .env file in the root directory:
# Backend
PORT=3000
# Blockchain
PRIVATE_KEY=your_private_key_here
RPC_URL=your_rpc_url_here
CONTRACT_ADDRESS=deployed_contract_address
# Game Configuration
GAME_DURATION=3600
ENTRY_FEE=0.01npm run devThis concurrently starts:
- Expo development server (React Native app)
- Express backend server
Frontend only
npm start
# or
npm run android # For Android
npm run ios # For iOS
npm run web # For web browserBackend only
npm run server- Compile contracts
cd contracts
npx hardhat compile- Deploy to network
npx hardhat run scripts/deploy.js --network <network-name>- Update contract addresses in backend configuration
- Generate types
cd subgraph
npm run codegen- Build subgraph
npm run build- Deploy to The Graph
graph deploy --studio <subgraph-name>- Timed Races: Players compete to solve word chains within a fixed time window
- Entry Fees: Players pay to join, creating a prize pool
- King of the Hill: Fastest solver becomes current leader
- Prize Distribution: 90% to winner, 10% platform fee
joinGame()- Pay entry fee and join the active gamerecordPlayerResult(address)- Oracle function to record completion time (admin only)finalizeGame()- Distribute prizes after game ends
Returns current game state, timer, and prize pool
Submit word guess for validation
{
"userAddress": "0x...",
"guess": "yourword"
}Admin endpoint to manually trigger a new game session
| Layer | Technology |
|---|---|
| Frontend | React Native, Expo, React Navigation |
| Backend | Node.js, Express.js |
| Smart Contracts | Solidity, Hardhat, OpenZeppelin |
| Blockchain | Ethereum (EVM-compatible) |
| Web3 Library | ethers.js v6 |
| Indexing | The Graph Protocol |
| Scheduling | node-cron |
| Development | Concurrently |
- Lobby - Browse and join active games
- Game Arena - Full-screen word chain gameplay
- Leaderboard - Global rankings and statistics
- Profile - User stats and game history
- Wallet - Web3 wallet integration and balance
- Entry validation prevents duplicate joins
- Time-locked prize distribution
- Admin-only oracle pattern for result recording
- OpenZeppelin contracts for security standards
- Error boundaries for graceful frontend failures
- Game Creation: Scheduler deploys new WagerQuest contract via QuestFactory
- Player Join: User pays entry fee via mobile app → Smart contract
- Gameplay: User submits guess → Backend validates → Records on-chain
- Completion: Backend detects winner → Calls
recordPlayerResult() - Finalization: After timer expires →
finalizeGame()distributes prizes - Indexing: Subgraph indexes all events for frontend queries
# Test smart contracts
cd contracts
npx hardhat test
# Test backend
cd backend
npm testThis project is licensed under the ISC License.
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a pull request
- Ensure all environment variables are properly configured
- Contract addresses must be updated after deployment
- Expo development requires network connectivity