Get ROYALSTACK running locally in 5 minutes.
- Node.js 18+
- Git
- A wallet (MetaMask recommended)
cd server
# Copy environment template
cp .env.example .env
# Fill in the .env file:
# - TURSO_CONNECTION_URL (from turso.tech)
# - TURSO_AUTH_TOKEN (from turso.tech)
# - REDIS_URL (from Upstash)
# - CONTRACT_ADDRESS (your deployed contract)
# - PROVIDER_RPC_URL (Mezo testnet)
nano .env
# Install dependencies
npm install
# Start server
npm startExpected output:
✓ Redis connected
✓ Turso connected
✓ EventListener connected to contract
✓ EventListener watching contract events
🚀 Server running on port 3002
cd ../client
# Copy environment template
cp .env.example .env
# Fill in:
# VITE_API_URL=http://localhost:3002
# VITE_WS_URL=http://localhost:3002
nano .env
# Install dependencies
npm install
# Start dev server
npm run devExpected output:
VITE v5.0.0 ready in 123 ms
➜ Local: http://localhost:5173/
# Get nonce
curl -X POST http://localhost:3002/api/auth/nonce \
-H "Content-Type: application/json" \
-d '{"walletAddress":"0x742d35Cc6634C0532925a3b844Bc9e7595f1e1d2"}'
# Response:
# {
# "nonce": "abc123...",
# "message": "ROYALSTACK Login: abc123...",
# "expiresIn": 300
# }- Open
http://localhost:5173in browser - Connect wallet (MetaMask testnet)
- Sign message to authenticate
- View dashboard & stats
- Create/join a pool
# If you haven't deployed yet:
# cd smart-contract
# npx hardhat deploy --network mezo-testnet-31611# Use web3.py or ethers.js to call contract
from web3 import Web3
import json
w3 = Web3(Web3.HTTPProvider("https://mezo-testnet-31611.rpc.io"))
# Call contract.createPool(initialDeposit)
# This should emit PoolCreated event
# EventListener will pick it up and initialize in RedisWatch server logs:
📍 PoolCreated: poolId=1, creator=0x..., deposit=1000
✓ Pool 1 initialized in Redis
# Call contract.deposit(poolId, amount)
# This should emit DepositMade eventWatch server logs:
💰 DepositMade: poolId=1, player=0x..., amount=500
🎮 Pool 1 has 1/5 players
// In browser console:
const client = new RoyalStackClient('http://localhost:3002');
// Restore session from localStorage
client.restoreSession();
// Connect
await client.connectWebSocket();
// Join pool
await client.game.joinPool(1);
// Listen for game updates
client.onGameStateUpdate((state) => {
console.log('Game state:', state);
});
// Send action
await client.game.sendAction({
type: 'bet',
amount: 100
});- Check Upstash credentials in
.env - Verify REDIS_URL is correct format
- Verify
TURSO_CONNECTION_URLandTURSO_AUTH_TOKEN - Make sure schema was initialized:
turso db shell <name> < db/schema.sql
- Ensure session token is stored in localStorage
- Check that
RoyalStackClienthas calledauth.verify()first
- Verify
PROVIDER_RPC_URLis correct for your chain - Check contract address matches deployment
- Ensure contract ABI matches event signatures
- Verify Redis is connected:
redis-cli ping - Check GameStateMachine is initialized
- Look for errors in server logs
turso db shell royalstack
# List tables
.tables
# Check player stats
SELECT * FROM player_stats;
# Check hands history
SELECT * FROM hands WHERE poolId = 1;
# Check actions for a hand
SELECT * FROM actions WHERE handId = 1 ORDER BY sequence;redis-cli
# Check active pools
KEYS room:*:state
# Get pool state
HGETALL room:1:state
# Get players in pool
HGETALL room:1:players
# Check sessions
KEYS session:*- Read
INTEGRATION_GUIDE.mdfor architecture overview - Implement missing engine methods (HandEvaluator, etc.)
- Build frontend UI components
- Add test suite
- Deploy to production (see
DEPLOYMENT.md)
# Server development with auto-reload
npm run dev
# View server logs
npm start 2>&1 | grep "✓\|✗\|error"
# Clear Redis cache
redis-cli FLUSHDB
# Reset database
turso db shell <name> < db/schema.sql
# Check blockchain connectivity
curl https://mezo-testnet-31611.rpc.io \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'- Server issues: Check
src/server.jslogs - Contract issues: Check EventListener output
- Frontend issues: Browser DevTools console
- Database issues: Query directly with Turso CLI or redis-cli
Happy playing! 🎰