A Node.js Express backend with Sui SDK integration and Pug frontend for playing blockchain-powered games like Sudoku and Maze puzzles.
- ๐ฎ Blockchain Games: Play Sudoku and Maze games with on-chain verification
- ๐ User Authentication: Secure user registration and login system
- ๐ Game Statistics: Track your progress and scores
- ๐ Leaderboards: Compete with other players
- ๐จ Modern UI: Beautiful, responsive interface built with Bootstrap and Pug
- โก Real-time Updates: Live network status and game state updates
- ๐ Security: Rate limiting, CORS protection, and input validation
- Node.js - Runtime environment
- Express.js - Web framework
- @mysten/sui.js - Sui blockchain SDK
- Pug - Template engine
- Bootstrap - CSS framework
- JWT - Authentication
- bcryptjs - Password hashing
- Pug - Template engine
- Bootstrap 5 - UI framework
- Font Awesome - Icons
- Vanilla JavaScript - Client-side functionality
- Node.js (v16 or higher)
- npm or yarn
- Sui CLI (for contract deployment)
- A Sui wallet (for testing)
-
Clone the repository
git clone <repository-url> cd suiridle
-
Install dependencies
npm install
-
Set up environment variables
cp env.example .env
Edit
.envfile with your configuration:PORT=3000 NODE_ENV=development SESSION_SECRET=your-secret-key JWT_SECRET=your-jwt-secret SUI_NETWORK=testnet SUIRIDLE_CONTRACT_ADDRESS=0x0 LABYRINTH_CONTRACT_ADDRESS=0x0 SUIDOKU_CONTRACT_ADDRESS=0x0
-
Deploy your Move contracts
cd suiridle_move sui move build sui client publish --gas-budget 10000000Update the contract addresses in your
.envfile with the deployed addresses. -
Start the development server
npm run dev
-
Visit the application Open your browser and go to
http://localhost:3000
suiridle/
โโโ config/
โ โโโ sui.js # Sui SDK configuration
โโโ routes/
โ โโโ authRoutes.js # Authentication routes
โ โโโ gameRoutes.js # Game logic routes
โ โโโ suiRoutes.js # Sui blockchain routes
โโโ views/
โ โโโ layout.pug # Main layout template
โ โโโ index.pug # Home page
โ โโโ games.pug # Games selection page
โ โโโ login.pug # Login page
โ โโโ register.pug # Registration page
โ โโโ dashboard.pug # User dashboard
โโโ public/
โ โโโ css/
โ โ โโโ style.css # Custom styles
โ โโโ js/
โ โโโ main.js # Main JavaScript file
โโโ server.js # Express server
โโโ package.json # Dependencies and scripts
โโโ README.md # This file
POST /api/auth/register- Register new userPOST /api/auth/login- User loginGET /api/auth/me- Get current userPUT /api/auth/profile- Update user profilePOST /api/auth/logout- User logout
GET /api/games- Get available gamesGET /api/games/stats/:address- Get user game statisticsGET /api/games/history/:address- Get user game historyGET /api/games/board/:objectId- Get game board detailsPOST /api/games/sudoku/solve- Submit Sudoku solutionPOST /api/games/maze/complete- Submit maze completion
GET /api/sui/network- Get network informationGET /api/sui/contracts- Get contract addressesGET /api/sui/object/:objectId- Get object detailsGET /api/sui/objects/:address- Get objects owned by addressGET /api/sui/games/:address- Get user's game boardsPOST /api/sui/maze/create- Create new maze gameGET /api/sui/maze/:objectId- Get maze detailsGET /api/sui/transaction/:digest- Get transaction details
- Classic 9x9 grid puzzles
- Multiple difficulty levels
- On-chain solution verification
- Score based on completion time and accuracy
- Procedurally generated mazes
- Multiple sizes (9x9, 15x15, 21x21)
- Path finding challenges
- On-chain path verification
npm run devnpm startnpm testnpm run build| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 3000 |
NODE_ENV |
Environment | development |
SESSION_SECRET |
Session secret key | Required |
JWT_SECRET |
JWT secret key | Required |
SUI_NETWORK |
Sui network | testnet |
SUI_FULLNODE_URL |
Sui fullnode URL | Auto-detected |
SUIRIDLE_CONTRACT_ADDRESS |
Main contract address | 0x0 |
LABYRINTH_CONTRACT_ADDRESS |
Maze contract address | 0x0 |
SUIDOKU_CONTRACT_ADDRESS |
Sudoku contract address | 0x0 |
The application supports different Sui networks:
- Testnet:
https://fullnode.testnet.sui.io:443 - Devnet:
https://fullnode.devnet.sui.io:443 - Mainnet:
https://fullnode.mainnet.sui.io:443
- Rate Limiting: Prevents abuse with configurable limits
- CORS Protection: Configurable cross-origin resource sharing
- Input Validation: Server-side validation for all inputs
- Password Hashing: Secure password storage with bcrypt
- JWT Authentication: Stateless authentication tokens
- Session Management: Secure session handling
- Helmet.js: Security headers and protection
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Join our Discord community
- Sui Foundation for the blockchain platform
- Mysten Labs for the Sui SDK
- Bootstrap for the UI framework
- Font Awesome for the icons
- Add more game types
- Implement NFT rewards
- Add multiplayer features
- Mobile app development
- Advanced leaderboards
- Tournament system
- Social features
- Analytics dashboard