Development Guide

This guide covers testing, debugging, and deploying your Games.fun integration.

Development Mode

The SDK includes a development mode for testing without real tokens:

const sdk = new GamesFunSDK({
    debug: true, // Enable debug logging
    gameServerUrl: "your-validation-endpoint",
    dev: {
        enabled: true,
        mock: {
            wallet: {
                address: 'ED5nyyWEzpPPiWimP8vYm7sD7TD3LAt3Q3gRTWHzPJBY',
                tokenBalance: '1000',
                solBalance: '10',
                privyId: '123'
            }
        },
        validation: {
            auto: true, // Auto-validate transfers
            makeRequest: true // Still hit your server
        }
    }
});

Environment Setup

Set up your environment variables:

Load them in your server:

Testing

Token Transfers

Test token transfers with dev mode:

Authentication

Test JWT flow:

WebSocket

Test real-time updates:

Debugging

Client Side

Enable debug logging:

Monitor WebSocket messages:

Server Side

Log validation requests:

Monitor state changes:

Deployment

Game Server

  1. Set up environment:

  1. Run server:

Client Side

  1. Build React app:

  1. Configure SDK:

Production Checklist

  1. Security

    • Validate all inputs

    • Use HTTPS

    • Set CORS headers

    • Rate limit requests

  2. Error Handling

    • Log all errors

    • Show user messages

    • Handle edge cases

    • Monitor issues

  3. Performance

    • Optimize state updates

    • Cache responses

    • Use WebSocket

    • Monitor latency

  4. Monitoring

    • Log key events

    • Track metrics

    • Set up alerts

    • Monitor uptime

Best Practices

  1. Development

    • Use TypeScript

    • Write tests

    • Document code

    • Follow patterns

  2. Testing

    • Unit tests

    • Integration tests

    • Load tests

    • Error scenarios

  3. Deployment

    • Use CI/CD

    • Stage changes

    • Back up data

    • Monitor logs

  4. Maintenance

    • Update packages

    • Check logs

    • Monitor usage

    • Handle issues