Core Concepts
Architecture Overview
Games.fun uses a multi-layered architecture to provide secure token-based gaming. Here's how the pieces fit together:
Game Client connects to two main services:
Games.fun Platform (via SDK) for token operations and authentication
Your Game Server (via WebSocket) for real-time game state
Games.fun Platform handles:
Token transfer validation on the blockchain
JWT authentication for your game server
Game wallet management
Your Game Server manages:
Game state and logic
Player inventory and points
Real-time communication with clients
This separation ensures secure token handling while giving you full control over your game's logic.
Key Components
1. Game Client
Uses Core SDK or React SDK
Handles user interactions
Manages game state
Triggers token actions
Maintains WebSocket connection
2. Games.fun Platform
Validates token transfers
Issues JWT tokens
Manages game wallets
Provides development tools
Handles blockchain interactions
3. Game Server
Validates actions
Manages game state
Handles WebSocket connections
Processes token/point conversions
Manages player inventory
Core Flows
Authentication Flow
Client requests JWT from platform
Platform issues signed token
Client includes token in game server connection
Game server verifies token with platform's public key
Token Transfer Flow
Player initiates token transfer
Platform validates on blockchain
Platform notifies game server
Game server updates player state
State changes broadcast via WebSocket
Game State Management
Client connects to game server
Server sends initial state
Client triggers actions
Server validates and processes
State updates sent to all clients
Key Concepts
Game Wallet
Each game has its own wallet
Receives player token transfers
Managed through server SDK
Used for withdrawals
Token/Point System
Tokens transferred to game wallet
Converted to game points
Points used for in-game actions
Points can be withdrawn as tokens
Action Validation
All actions validated by platform
Token transfers verified on chain
Game server validates game rules
JWT required for authenticated actions
Real-time Updates
WebSocket for live state changes
Immediate balance updates
Inventory synchronization
Action confirmations
Development Mode
The SDK includes a development mode that:
Mocks wallet connection
Simulates token balances
Auto-validates actions
Provides test data
Security Model
Authentication
JWT-based auth
RS256 signature verification
Automatic token refresh
Permission-based access
Token Security
On-chain validation
Game wallet verification
Amount validation
One-time-only credits
Game Server Security
Origin validation
Token validation
Rate limiting
Error handling
Next Steps
Last updated