Game Wallet

Each game on Games.fun has its own wallet that receives and manages player tokens. Your game wallet is the foundation for implementing token-based mechanics - players transfer tokens to it, and you convert them to points, items, or any in-game value.

The game wallet provides:

  • Secure token storage

  • Point conversion system

  • Withdrawal capabilities

  • Real-time balance tracking

Game Wallet Setup

First, create a wallet to receive player tokens:

// Using your API key
const response = await fetch('https://games.fun/api/games/wallet', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'x-api-key': 'your-games-fun-api-key'
    }
});

const { wallet } = await response.json();
const gameWalletAddress = wallet.address;

Store this wallet address - players will transfer tokens to it.

Token Transfers

Client Side

Players transfer tokens using the SDK:

Server Side

Your server validates and processes transfers:

Point System

You can implement any point conversion system. Here's a basic example:

Withdrawals

Let players withdraw their points back as tokens:

Error Handling

Handle common token scenarios:

Development Mode

Test token flows without real transfers:

Best Practices

  1. Validation

    • Always verify token type

    • Validate amounts and recipients

    • Check for duplicate transfers

    • Use atomic transactions

  2. State Management

    • Keep real-time balances

    • Handle disconnections

    • Sync client/server state

    • Log all transfers

  3. User Experience

    • Show clear token/point values

    • Explain conversion rates

    • Provide transaction history

    • Handle errors gracefully

Next Steps

Last updated