A real-time multiplayer chess game built with Next.js, Socket.io, and blockchain integration.
- Real-time Multiplayer Chess: Play chess games in real-time with other players
- Blockchain Integration: Connect your MetaMask wallet and place bets on games
- Smart Contract Integration: Automated bet placement and winnings distribution
- Responsive Design: Modern UI built with Bootstrap
- Game State Management: Real-time game synchronization using Socket.io
- Frontend: Next.js, React, Bootstrap
- Real-time Communication: Socket.io
- Blockchain: Ethereum (Goerli Testnet), MetaMask, Ethers.js
- Chess Engine: chess.js, chessboard.js
- Styling: Bootstrap 5, Custom CSS
socket-nextjs/
├── public/ # Static assets
│ ├── css/ # Chessboard CSS
│ ├── js/ # Chess libraries and utilities
│ ├── img/ # Chess piece images
│ └── contract/ # Smart contract ABI and source
├── src/
│ └── pages/ # Next.js pages
│ ├── index.jsx # Main lobby page
│ ├── white.jsx # White player game page
│ ├── black.jsx # Black player game page
│ ├── win.jsx # Win celebration page
│ ├── lost.jsx # Loss page
│ └── api/ # API routes
│ └── socket.js # Socket.io API
├── server.js # Custom server with Socket.io
├── config.js # Configuration file
└── package.json # Dependencies and scripts
-
Clone the repository
git clone <repository-url> cd socket-nextjs
-
Install dependencies
npm install
-
Start the development server
npm run dev
-
Open your browser Navigate to
http://localhost:3037
- Connect Wallet: Click "Connect Wallet" and connect your MetaMask wallet
- Create Game: Enter a bet amount and game code, then click "Create game"
- Join Game: Enter the game code provided by the creator and click "Join game"
- Play Chess: Make moves on the chessboard - only legal moves are allowed
- Win/Lose: The game ends when one player is checkmated or disconnects
- Claim Winnings: Winners can claim their bet through the smart contract
The game integrates with Ethereum smart contracts for:
- Game creation and bet placement
- Automatic winnings distribution
- Game state management on-chain
- Goerli Testnet:
0x6996b280785d92fd957B77D623E455ABdFfBF2D6
- White always moves first
- Only legal chess moves are allowed
- Games end on checkmate or player disconnection
- Disconnected players automatically lose
- Bets are locked in smart contracts until game completion
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLint
Create a .env.local file:
PORT=3037
NODE_ENV=development-
Build the application
npm run build
-
Start production server
npm run start
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
© 2024 Coullax All Rights Reserved
For support and questions, please contact the development team.