Core Concepts

Architecture Overview

Games.fun uses a multi-layered architecture to provide secure token-based gaming. Here's how the pieces fit together:

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

  2. Games.fun Platform handles:

    • Token transfer validation on the blockchain

    • JWT authentication for your game server

    • Game wallet management

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

  1. Client requests JWT from platform

  2. Platform issues signed token

  3. Client includes token in game server connection

  4. Game server verifies token with platform's public key

Token Transfer Flow

  1. Player initiates token transfer

  2. Platform validates on blockchain

  3. Platform notifies game server

  4. Game server updates player state

  5. State changes broadcast via WebSocket

Game State Management

  1. Client connects to game server

  2. Server sends initial state

  3. Client triggers actions

  4. Server validates and processes

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

  1. Authentication

    • JWT-based auth

    • RS256 signature verification

    • Automatic token refresh

    • Permission-based access

  2. Token Security

    • On-chain validation

    • Game wallet verification

    • Amount validation

    • One-time-only credits

  3. Game Server Security

    • Origin validation

    • Token validation

    • Rate limiting

    • Error handling

Next Steps

Last updated