Skip to content

This repository is about practicing randomness on move (on sui) and trying to implement fun puzzle games

Notifications You must be signed in to change notification settings

25bahaz/suiridle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Suiridle - Blockchain Games on Sui

A Node.js Express backend with Sui SDK integration and Pug frontend for playing blockchain-powered games like Sudoku and Maze puzzles.

Features

  • ๐ŸŽฎ 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

Tech Stack

Backend

  • 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

Frontend

  • Pug - Template engine
  • Bootstrap 5 - UI framework
  • Font Awesome - Icons
  • Vanilla JavaScript - Client-side functionality

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • Sui CLI (for contract deployment)
  • A Sui wallet (for testing)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd suiridle
  2. Install dependencies

    npm install
  3. Set up environment variables

    cp env.example .env

    Edit .env file 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
  4. Deploy your Move contracts

    cd suiridle_move
    sui move build
    sui client publish --gas-budget 10000000

    Update the contract addresses in your .env file with the deployed addresses.

  5. Start the development server

    npm run dev
  6. Visit the application Open your browser and go to http://localhost:3000

Project Structure

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

API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - User login
  • GET /api/auth/me - Get current user
  • PUT /api/auth/profile - Update user profile
  • POST /api/auth/logout - User logout

Games

  • GET /api/games - Get available games
  • GET /api/games/stats/:address - Get user game statistics
  • GET /api/games/history/:address - Get user game history
  • GET /api/games/board/:objectId - Get game board details
  • POST /api/games/sudoku/solve - Submit Sudoku solution
  • POST /api/games/maze/complete - Submit maze completion

Sui Blockchain

  • GET /api/sui/network - Get network information
  • GET /api/sui/contracts - Get contract addresses
  • GET /api/sui/object/:objectId - Get object details
  • GET /api/sui/objects/:address - Get objects owned by address
  • GET /api/sui/games/:address - Get user's game boards
  • POST /api/sui/maze/create - Create new maze game
  • GET /api/sui/maze/:objectId - Get maze details
  • GET /api/sui/transaction/:digest - Get transaction details

Game Types

Sudoku

  • Classic 9x9 grid puzzles
  • Multiple difficulty levels
  • On-chain solution verification
  • Score based on completion time and accuracy

Mysten Labyrinth

  • Procedurally generated mazes
  • Multiple sizes (9x9, 15x15, 21x21)
  • Path finding challenges
  • On-chain path verification

Development

Running in Development Mode

npm run dev

Running in Production Mode

npm start

Running Tests

npm test

Building for Production

npm run build

Configuration

Environment Variables

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

Network Configuration

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

Security Features

  • 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

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter any issues or have questions:

  1. Check the Issues page
  2. Create a new issue with detailed information
  3. Join our Discord community

Acknowledgments

Roadmap

  • Add more game types
  • Implement NFT rewards
  • Add multiplayer features
  • Mobile app development
  • Advanced leaderboards
  • Tournament system
  • Social features
  • Analytics dashboard

About

This repository is about practicing randomness on move (on sui) and trying to implement fun puzzle games

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published