Skip to content

About

Latch on Solana is a real-time multiplayer PvP battle platform built on Solana where players wager SOL, fight in fast-paced matches, and receive trustless on-chain payouts through escrow settlement.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Latch

A real-time PvP wagering game powered by Solana.

Latch combines competitive multiplayer gameplay with blockchain-backed prize settlement. Players stake cryptocurrency, battle in real-time arenas, and receive automated payouts directly through Solana smart contracts.


Why Latch?

Traditional online gaming platforms rely on centralized systems to manage entry fees, match outcomes, and rewards — players must trust the platform to handle funds fairly.

Latch addresses this by using blockchain technology for wager custody and payouts while keeping gameplay fast through a traditional game server architecture:

  • Players maintain ownership of their funds until they enter a match
  • Wagers are locked in a transparent on-chain escrow
  • Match outcomes are validated by the authoritative game server
  • Prize payouts are executed automatically through Solana smart contracts
  • Players can verify all transactions directly on-chain

What Does Latch Do?

Latch allows players to:

  1. Connect a Solana wallet
  2. Join or create a wager-based match
  3. Deposit funds into a secure on-chain vault
  4. Compete in a real-time multiplayer battle
  5. Win the match and receive the combined prize pool

The platform combines the speed of modern multiplayer gaming with the transparency and security of blockchain settlement.


Current Implementation

What's built

Layer Status Stack
Frontend game client ✅ Complete Phaser 3, Vite
Multiplayer server ✅ Complete Node.js, Express, Socket.io
Wallet authentication ✅ Complete Solana Wallet Standard, Phantom, Backpack
User accounts ✅ Complete PostgreSQL (NeonDB)
On-chain escrow & payouts 🔜 In progress Solana, Anchor

Architecture

latch/
├── frontend/   Vite + Phaser 3 game client
└── server/     Express + Socket.io multiplayer server

Running Locally

Prerequisites

  • Node.js 18+
  • A Solana wallet extension (Phantom or Backpack) set to Devnet
  • A PostgreSQL database — NeonDB free tier works well

1. Server

cd server
npm install

Create server/.env (copy from .env.example):

DATABASE_URL=postgresql://user:password@host/dbname?sslmode=require
PORT=3001
node server.js
# → migrate: applied 001_create_users.sql
# → Server running on port 3001

2. Frontend

cd frontend
npm install
npm run dev
# → http://localhost:8080

Open a second browser tab to test multiplayer.


How It Works

Step 1: Wallet Connection

Players connect a supported Solana wallet:

  • Phantom
  • Backpack
  • Solflare
  • Any Wallet Standard extension

The wallet serves as the player's identity and enables secure transaction signing. Extensions are auto-detected on page load — no manual selection needed if only one is installed.

Step 2: Authentication & Account

On first connect, players pick a unique username (3–20 alphanumeric characters). Username and wallet address are stored in PostgreSQL. Returning players are recognized automatically and skip straight to the game.

Step 3: Create or Join a Battle

A player can:

  • Create a new battle with a chosen wager amount
  • Join an existing battle created by another player

Once two players are matched, the battle begins.

Step 4: Deposit Wagers (in progress)

Before entering the arena:

  • Each player deposits their wager
  • Funds are sent directly to a Solana smart contract
  • The smart contract locks the funds in a secure escrow vault

Neither player nor the backend can withdraw these funds during the match.

Step 5: Real-Time Combat

The game runs in the browser using Phaser 3 and communicates with the backend through WebSockets (Socket.io).

The backend acts as the authoritative game server:

  • Synchronizes player positions and animations
  • Validates combat events and applies damage
  • Determines the final winner
  • Broadcasts results to all players in the scene

Players are isolated by scene — only players in the same area interact.

Controls: arrow keys to move · Space to attack · T to chat

Step 6: Match Resolution (in progress)

When the battle ends:

  • The backend verifies the winner
  • A settlement request is triggered
  • The Solana program validates the battle state

Only valid matches can be settled.

Step 7: Prize Distribution (in progress)

After successful validation:

  • The entire prize pool is released from escrow
  • Funds are transferred directly to the winner's wallet
  • The transaction is recorded permanently on-chain

Players can independently verify the payout using a Solana explorer.


Game Flow

Connect Wallet
       │
       ▼
Auth + Username Registration
       │
       ▼
Character Select
       │
       ▼
Create / Join Match
       │
       ▼
Deposit Wager  ← (in progress)
       │
       ▼
Real-Time Battle
       │
       ▼
Winner Determined (server-authoritative)
       │
       ▼
Smart Contract Settlement  ← (in progress)
       │
       ▼
Prize Sent To Winner

System Architecture

Frontend

  • Game rendering and player controls
  • Wallet detection via Wallet Standard + legacy window.* injection
  • Devnet verification via Solana JSON-RPC (no @solana/web3.js dependency)
  • REST calls to server for user lookup / registration
  • Real-time sync via Socket.io client

Tech: Phaser 3, Vite, Socket.io Client

Backend

  • Authentication and user account management (PostgreSQL)
  • Real-time game state, movement, and combat validation
  • Scene-based player rooms — players only interact within the same scene
  • SQL migrations applied automatically on boot

Tech: Node.js, Express, Socket.io, PostgreSQL (NeonDB)

Solana Program (in progress)

  • Escrow management and vault accounts
  • Battle state storage via PDAs
  • Automated payout execution
  • Refund handling for cancelled matches

Tech: Solana, Anchor Framework, Program Derived Addresses


Security Design

On-chain escrow — Player funds are stored in program-controlled vault accounts, not backend wallets. No need to trust the platform with custody.

Wallet-based authentication — Users authenticate through cryptographic signatures. No passwords.

Server-authoritative gameplay — The backend validates all critical gameplay events to prevent cheating.

Transparent settlement — Every deposit, refund, and payout is verifiable directly on the Solana blockchain.


Project Goal

Latch demonstrates how blockchain technology can be integrated into multiplayer gaming without sacrificing gameplay speed or user experience.

The project explores a model where:

  • Competitive games become trust-minimized
  • Prize pools are managed transparently
  • Players retain visibility into how funds move
  • Match outcomes can be settled securely and automatically

By combining real-time multiplayer infrastructure with Solana smart contracts, Latch creates a foundation for skill-based gaming with verifiable rewards.

About

Latch on Solana is a real-time multiplayer PvP battle platform built on Solana where players wager SOL, fight in fast-paced matches, and receive trustless on-chain payouts through escrow settlement.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages