Skip to main content

⚠️ Developer Preview

The Gx402 SDK is still in active development.
Some features may not function as expected, and APIs are subject to change.
For production use, please wait for the stable release.

Basic Integration Tutorial

This tutorial will guide you through integrating the Gx402 SDK into an existing game project, covering the essential steps to get x402 functionality working.

Overview

By the end of this tutorial, you will have:
  • Integrated the Gx402 SDK into your game
  • Set up basic x402 processing
  • Implemented simple data synchronization
  • Added user authentication

Prerequisites

  • An existing game project (Unity, Unreal, WebGL, or other supported platform)
  • A Gx402 API key from your dashboard
  • Basic knowledge of your game’s architecture

Step 1: Install the SDK

For WebGL/JavaScript Projects

If you’re using NPM:
If you prefer CDN, add to your HTML:

For Unity Projects

  1. Open your Unity project
  2. Go to Window > Package Manager
  3. Click the + button and select “Add package from git URL”
  4. Enter: https://github.com/Gx402/unity-sdk.git

For Unreal Engine Projects

  1. Download the plugin from Releases
  2. Create a Plugins folder in your project if it doesn’t exist
  3. Extract the plugin to YourProject/Plugins/Gx402-sdk
  4. Restart Unreal Editor and enable the plugin

Step 2: Initialize the SDK

WebGL/JavaScript

Unity (C#)

Unreal Engine (C++)

Step 3: Add User Authentication

Authentication is crucial for personalized x402 experiences.

WebGL/JavaScript

Unity (C#)

Step 4: Implement x402 Data Processing

Now let’s add x402 processing to your game data.

WebGL/JavaScript

Unity (C#)

Step 5: Add Data Synchronization

Enable real-time synchronization between players.

WebGL/JavaScript

Step 6: Implement Error Handling

Add robust error handling for production use.

Step 7: Testing Your Integration

Test Scenarios

  1. Basic Functionality
    • Initialize the SDK
    • Process simple data through x402
    • Verify authentication works
  2. Sync Functionality
    • Multiple clients connecting
    • Data synchronization between clients
    • Offline/online transitions
  3. Performance
    • SDK initialization time
    • x402 processing overhead
    • Memory usage

Debugging Tips

Step 8: Production Setup

When deploying to production:
  1. Update Configuration
  2. Security Considerations
    • Never hardcode API keys in client code
    • Use environment variables or secure token management
    • Implement proper access controls
  3. Performance Optimization
    • Reduce debug logging
    • Optimize sync frequency
    • Implement smart caching

Troubleshooting

Common Issues

SDK Not Initializing
  • Check your API key is valid
  • Verify network connectivity
  • Ensure correct environment configuration
Sync Not Working
  • Confirm real-time sync is enabled
  • Check authentication status
  • Verify proper event listeners are set up
High Latency
  • Optimize sync frequency
  • Batch multiple operations
  • Consider regional endpoints

Next Steps

Now that you have the basic integration working:
  1. Explore advanced features in the Features Documentation
  2. Check platform-specific guides in the Platform Documentation
  3. Review the complete API Reference
  4. Join our Community for support and updates

Complete Integration Example

Here’s a complete example showing all the pieces together:
You now have a solid foundation for using the Gx402 SDK in your game!