llmsdottxt

This guide helps AI models understand how to build games using the games.fun platform SDKs.

Packages

  1. @games-fun/sdk

  • Core SDK for game integration

  • Token transfers and validation

  • Authentication and state management

  • Development mode for testing

  1. @games-fun/react

  • React hooks and components

  • Context provider for SDK

  • State management utilities

  • Built-in UI components

  1. @games-fun/server-sdk

  • Game server utilities

  • Wallet management

  • JWT verification

  • WebSocket helpers

Installation

Core Integration Steps

1. Game Wallet Setup

  1. Get API key after deploying game

  2. Create or get game wallet:

  1. Store wallet address for token transfers

2. Authentication Setup

  1. Server setup - get public key:

  1. Client authentication:

  1. WebSocket authentication:

3. Token Transfer Flow

  1. Client initializes SDK with validation endpoint:

  1. Client triggers transfer:

  1. Platform validates and hits your endpoint:

  1. Your server processes validation:

Initial Setup

  1. Deploy your game to get an API key

  2. Create a game wallet to receive token transfers:

Core Concepts

  1. 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

  1. 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

  1. 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:

  1. Client triggers action:

  1. Platform validates and forwards:

  1. Game server validates and processes:

  1. 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:

  1. Client requests withdrawal:

  1. 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.