A Next-Generation NFT-Based Space Shooter Game on Stellar Blockchain
Features โข Installation โข Smart Contracts โข Deployment โข Documentation
https://youtu.be/auC2VgekLhI?si=E9sW-NqZyDuW604C
Space Stellar is a decentralized web3 game built on the Stellar blockchain, combining NFT collectibles with real-time space shooter gameplay. This project uses Scaffold Stellar Registry to easily manage and deploy smart contracts.
Space Stellar is a Play-to-Earn NFT Game where:
- Players Collect NFT Ships - Each ship is a unique NFT with different attributes (Attack, Speed, Shield)
- Play Space Shooter Game - Use NFT ships to play real-time games
- Global Competition - Climb the leaderboard rankings and earn rewards
- Multiplayer Support - Play solo or versus with other players
This project uses the Scaffold Stellar Registry System for smart contract deployment:
- Registry Contract: On-chain contract for publishing, deploying, and managing smart contracts
- Registry CLI: Tool for interacting with the registry (
stellar registrycommands) - OpenZeppelin Standards: Uses OpenZeppelin Stellar Contracts for NFT standards
- Soroban Smart Contracts: Smart contracts written in Rust using Soroban SDK
- Simplified Deployment: No need to manage contract IDs manually
- Version Management: Registry stores all published contract versions
- Easy Updates: Update contracts easily without losing data
- Alias System: Use alias names to simplify development
- On-chain Registry: All contracts are registered on the blockchain for transparency
Full Documentation: Scaffold Stellar Registry Guide
-
Space Shooter Mechanics
- Player ship movement (WASD/Arrow Keys)
- Shooting system with customizable fire rate
- Enemy spawning with difficulty scaling
- Collision detection and health system
- Score tracking and coin collection
- Power-ups and special abilities
-
Game Modes
- Solo Mode: Single-player gameplay with global leaderboard
- Multiplayer Mode: Room-based versus matches with real-time synchronization
-
Ship System
- 6-tier rarity system (Classic, Elite, Epic, Legendary, Master, Ultra)
- Unique stats per tier (Attack, Speed, Shield)
- Dynamic ship attributes that affect gameplay
- Visual ship representation with GIF animations
-
NFT Minting
- Mint unique ship NFTs directly from the store
- IPFS-based metadata storage
- On-chain attribute storage (class, rarity, tier, stats)
- Sequential token ID assignment
- NFT Ship Contract (Testnet):
CC7MQ3BSNULZ4YX62OMZOZ2RYTZEMUJEWITQJH7YBVXJL75QIZMS2PTX
-
Collection Management
- View owned NFTs in the collection page
- Ship equipping system
- Profile picture (PFP) NFT support
- Transfer and ownership tracking
-
Leaderboards
- Global top players ranking
- Best score tracking per player
- Real-time leaderboard updates
-
Match History
- Complete game history per player
- Match statistics (score, duration, mode)
- Room code tracking
-
Profile System
- User profile with statistics
- NFT ownership display
- Achievement tracking
space-stellar/
โโโ frontend/ # React + TypeScript frontend
โ โโโ src/
โ โ โโโ components/ # Reusable UI components
โ โ โโโ pages/ # Route pages
โ โ โโโ contexts/ # React contexts (Wallet)
โ โ โโโ contracts/ # Generated contract clients
โ โ โโโ utils/ # Utility functions
โ โโโ public/ # Static assets
โ โโโ package.json
โ
โโโ backend/ # Node.js + Express backend
โ โโโ routes/ # API routes
โ โโโ scripts/ # Migration & utility scripts
โ โโโ utils/ # Utility functions
โ โโโ server.js # Express server
โ
โโโ contracts/ # Soroban smart contracts (Rust)
โ โโโ space_stellar_nft/ # Main NFT contract (Ships)
โ โ โโโ src/lib.rs # Contract implementation
โ โ โโโ Cargo.toml
โ โโโ space_stellar_pfp/ # Profile Picture NFT contract
โ โ โโโ src/lib.rs # PFP contract implementation
โ โ โโโ Cargo.toml
โ โโโ Cargo.toml # Workspace configuration
โ
โโโ scripts/ # Deployment scripts
โโโ scaffold.config.js # Scaffold Stellar configuration
โโโ package.json # Root package.json
Frontend:
- React 19.1.1 with TypeScript
- Vite 7.1.11 for build tooling
- Stellar Wallet Kit for wallet integration
- React Router for navigation
- TanStack Query for data fetching
Backend:
- Node.js with Express
- PostgreSQL for data persistence (optional)
- Socket.io for real-time multiplayer
Smart Contracts:
- Rust with Soroban SDK 23.0.2
- OpenZeppelin Stellar Contracts v0.5.1
- Scaffold Stellar Registry for deployment and management
Blockchain:
- Stellar Network (Testnet/Mainnet)
- Soroban for smart contract execution
- IPFS for metadata storage
- Node.js 18+ and npm
- Rust 1.70+ and Cargo
- PostgreSQL 14+ (optional, backend can run in mock mode)
- Stellar CLI - for contract deployment
- Scaffold Stellar CLI - for registry management
git clone https://github.com/enyekk7/space-stellar.git
cd space-stellar# Install root dependencies
npm install
# Install frontend dependencies
cd frontend && npm install && cd ..
# Install backend dependencies
cd backend && npm install && cd ..# Install Rust toolchain (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install wasm32 target for contract compilation
rustup target add wasm32-unknown-unknown# Install Scaffold Stellar CLI
cargo install --locked stellar-scaffold-cli
# Install Registry CLI (for registry management)
cargo install --git https://github.com/theahaco/scaffold-stellar stellar-registry-cliReference: Scaffold Stellar Registry Installation
Create environment files:
Frontend (frontend/.env):
VITE_STELLAR_NETWORK=testnet
VITE_CONTRACT_ID=your_nft_contract_id_here
VITE_PFP_CONTRACT_ID=your_pfp_contract_id_here
VITE_API_URL=http://localhost:3001
VITE_SOCKET_URL=http://localhost:3001
VITE_TREASURY_ADDRESS=your_treasury_address_hereBackend (backend/.env):
PORT=3001
NODE_ENV=development
STELLAR_NETWORK=testnet
SOROBAN_RPC_URL=https://soroban-rpc.testnet.stellar.org
HORIZON_URL=https://horizon-testnet.stellar.org
# Contract IDs (fill after deployment)
CONTRACT_ID=your_nft_contract_id
PFP_CONTRACT_ID=your_pfp_contract_id
# Database (optional)
DATABASE_URL=postgresql://user:password@localhost:5432/space_stellar
# JWT Secret
JWT_SECRET=your_random_jwt_secret_key_here
# IPFS (if using Pinata)
PINATA_API_KEY=your_pinata_api_key
PINATA_SECRET_KEY=your_pinata_secret_key
# Contract Owner (for PFP minting)
PFP_CONTRACT_OWNER_SECRET=your_owner_secret_key_here# Build all contracts
npm run deploy:build
# Or build individually
cd contracts/space_stellar_nft
cargo build --target wasm32-unknown-unknown --release
cd ../space_stellar_pfp
cargo build --target wasm32-unknown-unknown --release
cd ../..Terminal 1 - Backend:
cd backend
npm run devTerminal 2 - Frontend:
cd frontend
npm run devTerminal 3 - Scaffold Stellar Watch (Optional):
npm run dev
# This will watch for contract changes and rebuild clientsOpen your browser at http://localhost:5173
This project uses 2 smart contracts deployed using Scaffold Stellar Registry:
Main NFT contract for ship tokens with custom metadata.
- Name: Space Stellar Ships
- Symbol: SSHIP
- Standard: OpenZeppelin NonFungibleToken
- Features: Ownable, Sequential Minting, Custom Metadata
- Deployment: Uses Scaffold Stellar Registry
-
Initialization (Constructor)
pub fn __constructor(e: &Env, owner: Address)
- Sets contract metadata (name, symbol, URI)
- Sets contract owner
- Initializes OpenZeppelin base contract
-
Minting Process
pub fn mint( e: &Env, to: Address, class: String, // Ship class (Elite, Epic, etc.) rarity: String, // Rarity level tier: String, // Tier level attack: u32, // Attack stat speed: u32, // Speed stat shield: u32, // Shield stat ipfs_cid: String, // IPFS content ID metadata_uri: String // Full metadata URI ) -> u32 // Returns token ID
Minting Flow:
- User selects ship tier on Store page
- Frontend creates payment transaction to Treasury address
- After payment is confirmed, frontend calls
mint()function - Contract uses
Base::sequential_mint()to mint NFT - Metadata is stored on-chain (class, rarity, tier, stats, IPFS CID)
- Token ID is returned and displayed to user
-
Metadata Storage
- Ship attributes stored on-chain using instance storage
- IPFS CID for off-chain metadata JSON
- Full metadata URI for external access
-
OpenZeppelin Traits
NonFungibleToken: Standard NFT operations (transfer, approve, etc.)Ownable: Contract ownership management
// Get ship metadata
pub fn get_ship_class(e: &Env, token_id: u32) -> Option<String>
pub fn get_ship_rarity(e: &Env, token_id: u32) -> Option<String>
pub fn get_ship_tier(e: &Env, token_id: u32) -> Option<String>
pub fn get_ipfs_cid(e: &Env, token_id: u32) -> Option<String>
pub fn get_metadata_uri(e: &Env, token_id: u32) -> Option<String>NFT contract for Profile Picture - one PFP per address.
- Name: Space Stellar PFP
- Symbol: SSPFP
- Standard: OpenZeppelin NonFungibleToken
- Features: One-per-address minting, Sequential IDs
- Deployment: Uses Scaffold Stellar Registry
-
Initialization
pub fn __constructor(e: &Env, owner: Address)
- Sets contract metadata
- Sets contract owner
-
Minting Process
pub fn mint(e: &Env, to: Address) -> u32
Minting Flow:
- User selects PFP on Profile page
- Frontend/Backend calls
mint()function - Contract checks if address already has PFP (
balance > 0) - If not, contract mints PFP using
Base::sequential_mint() - Token ID is returned
-
Minting Rules
- Each address can only mint one PFP
- Public minting (anyone can call)
- Sequential token IDs (1, 2, 3, ...)
-
Check Function
pub fn has_pfp(e: &Env, owner: Address) -> bool
- Checks if address already has PFP
- Uses
Base::balance()for checking
This project uses Scaffold Stellar Registry for smart contract deployment. The registry system simplifies publishing, deploying, and managing contracts.
-
Install Registry CLI:
cargo install --git https://github.com/theahaco/scaffold-stellar stellar-registry-cli
-
Setup Stellar Account:
stellar keys use alice stellar network use testnet
-
Fund Account:
- Testnet: Use Friendbot
- Mainnet: Transfer XLM to account
# Build NFT contract
cd contracts/space_stellar_nft
cargo build --target wasm32-unknown-unknown --release
# Build PFP contract
cd ../space_stellar_pfp
cargo build --target wasm32-unknown-unknown --release
cd ../..Publish NFT Contract:
stellar registry publish \
--wasm target/wasm32-unknown-unknown/release/space_stellar_nft.wasm \
--wasm-name space-stellar-nft \
--binver "1.0.0" \
--network testnetPublish PFP Contract:
stellar registry publish \
--wasm target/wasm32-unknown-unknown/release/space_stellar_pfp.wasm \
--wasm-name space-stellar-pfp \
--binver "1.0.0" \
--network testnetExplanation:
--wasm: Path to compiled WASM file--wasm-name: Name for published contract (will be used for deployment)--binver: Binary version (follows semantic versioning)--network: Target network (testnet/mainnet)
Deploy NFT Contract:
stellar registry deploy \
--contract-name space-stellar-nft-instance \
--wasm-name space-stellar-nft \
--version "1.0.0" \
--network testnet \
-- \
__constructor \
--owner YOUR_OWNER_ADDRESSDeploy PFP Contract:
stellar registry deploy \
--contract-name space-stellar-pfp-instance \
--wasm-name space-stellar-pfp \
--version "1.0.0" \
--network testnet \
-- \
__constructor \
--owner YOUR_OWNER_ADDRESSExplanation:
--contract-name: Name for deployed contract instance--wasm-name: Name of published contract to deploy--version: Specific version (optional, default: latest)--: Separator for constructor function and arguments__constructor: Constructor function name--owner: Owner address for contract
Aliases simplify contract usage with memorable names:
# Create alias for NFT contract
stellar registry create-alias space-stellar-nft-instance
# Create alias for PFP contract
stellar registry create-alias space-stellar-pfp-instanceAfter creating aliases, you can use them directly:
stellar contract invoke --id space-stellar-nft-instance -- --helpAfter deployment, get the Contract ID:
# Get Contract ID from alias
stellar keys lookup space-stellar-nft-instance
# Or from registry
stellar registry info space-stellar-nft-instanceUpdate Contract IDs in environment files:
frontend/.env:VITE_CONTRACT_IDandVITE_PFP_CONTRACT_IDbackend/.env:CONTRACT_IDandPFP_CONTRACT_ID
This project provides deployment scripts:
PowerShell (Windows):
.\scripts\deploy-scaffold.ps1 -Network testnetBash (Linux/Mac):
./scripts/deploy-scaffold.sh testnet# Check contract metadata
stellar contract invoke --id space-stellar-nft-instance -- name
stellar contract invoke --id space-stellar-nft-instance -- symbol
# Test mint NFT
stellar contract invoke \
--id space-stellar-nft-instance \
-- \
mint \
--to RECIPIENT_ADDRESS \
--class "Elite" \
--rarity "Common" \
--tier "Tier 1" \
--attack 10 \
--speed 8 \
--shield 12 \
--ipfs_cid "QmExample..." \
--metadata_uri "ipfs://QmExample..."
# Test mint PFP
stellar contract invoke \
--id space-stellar-pfp-instance \
-- \
mint \
--to RECIPIENT_ADDRESS- Semantic Versioning: Use semantic versioning for contract versions
- Test on Testnet: Always test deployment on testnet before mainnet
- Dry Run: Use
--dry-runflag to simulate operations - Documentation: Document initialization parameters for each deployment
- Environment Variables: Use environment variables for network configurations
Full Reference: Scaffold Stellar Registry Guide
| Tier | Rarity | Price (XLM) | Attack | Speed | Shield | Total Stats |
|---|---|---|---|---|---|---|
| Classic | Default | Free | 5 | 5 | 5 | 15 |
| Elite | Common | 10 | 10 | 8 | 12 | 30 |
| Epic | Epic | 50 | 20 | 6 | 18 | 44 |
| Legendary | Legendary | 100 | 30 | 15 | 25 | 70 |
| Master | Master | 200 | 40 | 12 | 35 | 87 |
| Ultra | Ultra | 500 | 50 | 18 | 45 | 113 |
Ship stats affect gameplay:
- Speed: Movement velocity (pixels per frame)
- Fire Rate: Bullet firing interval (milliseconds)
- Health: Hit points before game over
Rarity-based Stats:
- Classic: Speed 5, Fire Rate 300ms, Health 3
- Common/Elite: Speed 6, Fire Rate 250ms, Health 4
- Epic: Speed 7, Fire Rate 200ms, Health 5
- Legendary: Speed 8, Fire Rate 150ms, Health 6
- Master: Speed 9, Fire Rate 120ms, Health 7
- Ultra: Speed 10, Fire Rate 100ms, Health 8
- Movement:
WASDorArrow Keys - Shoot:
Space - Pause:
P
- Enemy destroyed: +10 points
- Coin collected: +5 points
- Difficulty scaling: Enemy speed increases with score
// Create a new game room
POST /api/rooms/create
Body: {
hostAddress: string
mode: 'solo' | 'versus' | 'multiplayer'
seed?: number
}
Response: {
roomCode: string
roomId: string
status: 'waiting' | 'playing' | 'finished'
}
// Get room data
GET /api/rooms/:roomCode
Response: {
roomId: string
hostAddress: string
guestAddress?: string
mode: string
status: string
seed: number
created_at: string
}// Save match result
POST /api/matches/save
Body: {
mode: string
p1_address: string
p2_address?: string
p1_score: number
p2_score?: number
duration_ms: number
room_code: string
}
Response: {
matchId: string
success: boolean
}
// Get leaderboard
GET /api/matches/leaderboard
Query: ?limit=10
Response: {
leaderboard: Array<{
address: string
best_score: number
updated_at: string
}>
}# Development
npm run dev # Run frontend + scaffold watch
npm start # Same as dev
# Building
npm run build # Build frontend + contracts
npm run deploy:build # Build contracts only
# Contract Deployment
npm run deploy:testnet # Deploy to testnet
npm run deploy:mainnet # Deploy to mainnet# Build contract
cd contracts/space_stellar_nft
cargo build --target wasm32-unknown-unknown --release
# Test contract
cargo test
# Check contract size
ls -lh target/wasm32-unknown-unknown/release/space_stellar_nft.wasm- Stellar Documentation
- Soroban Documentation
- Scaffold Stellar
- Scaffold Stellar Registry Guide โญ
- Stellar Wallet Kit
- OpenZeppelin Stellar Contracts
contracts/README.md- Detailed smart contracts documentationGIT_FILTER.md- Git filter documentation
We welcome contributions! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow TypeScript/JavaScript best practices
- Use ESLint and Prettier configurations
- Write meaningful commit messages
- Add tests for new features
- Follow Rust best practices
- Ensure contracts are optimized for size
- Add comprehensive tests
- Document all public functions
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- Stellar Development Foundation for the amazing blockchain platform
- OpenZeppelin for Stellar smart contract standards
- Scaffold Stellar team for the development framework and registry system
- All contributors and community members
- Repository: GitHub
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Built with โค๏ธ on Stellar using Scaffold Stellar Registry
Website โข Documentation