llmsdottxt
This guide helps AI models understand how to build games using the games.fun platform SDKs.
Packages
@games-fun/sdk
Core SDK for game integration
Token transfers and validation
Authentication and state management
Development mode for testing
@games-fun/react
React hooks and components
Context provider for SDK
State management utilities
Built-in UI components
@games-fun/server-sdk
Game server utilities
Wallet management
JWT verification
WebSocket helpers
Installation
Core Integration Steps
1. Game Wallet Setup
Get API key after deploying game
Create or get game wallet:
Store wallet address for token transfers
2. Authentication Setup
Server setup - get public key:
Client authentication:
WebSocket authentication:
3. Token Transfer Flow
Client initializes SDK with validation endpoint:
Client triggers transfer:
Platform validates and hits your endpoint:
Your server processes validation:
Initial Setup
Deploy your game to get an API key
Create a game wallet to receive token transfers:
Core Concepts
Token System
Players transfer tokens to game wallet
Games can:
Convert tokens to points with custom ratio
Sell items directly for tokens
Use any token-based economy
All conversions handled by game server
Action Validation
Platform verifies token transfers on chain
Forwards validation to game server
Includes transfer details and context
One-time-only credit of points/items
Authentication
JWT-based auth for game actions
Required for purchases/withdrawals
Tokens verified with RS256
Authentication Flow
1. Server Setup
First, get the platform's public key for JWT verification:
2. Client Implementation
Vanilla JavaScript:
React Implementation:
3. WebSocket Authentication
4. Error Handling
Validation Flow
When a player transfers tokens:
Client triggers action:
Platform validates and forwards:
Game server validates and processes:
Game server sends state update:
Vanilla JavaScript Integration
React Integration
Game Server Integration
Token Withdrawal Flow
When a player wants to withdraw points as tokens:
Client requests withdrawal:
Game server processes withdrawal:
Development Mode
Enable dev mode for testing:
Error Handling
This guide covers everything needed to integrate games with the games.fun platform, with specific patterns for vanilla JS, React, and game server implementations.