⚠️ 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.
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:For Unity Projects
- Open your Unity project
- Go to
Window>Package Manager - Click the
+button and select “Add package from git URL” - Enter:
https://github.com/Gx402/unity-sdk.git
For Unreal Engine Projects
- Download the plugin from Releases
- Create a
Pluginsfolder in your project if it doesn’t exist - Extract the plugin to
YourProject/Plugins/Gx402-sdk - 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
-
Basic Functionality
- Initialize the SDK
- Process simple data through x402
- Verify authentication works
-
Sync Functionality
- Multiple clients connecting
- Data synchronization between clients
- Offline/online transitions
-
Performance
- SDK initialization time
- x402 processing overhead
- Memory usage
Debugging Tips
Step 8: Production Setup
When deploying to production:-
Update Configuration
-
Security Considerations
- Never hardcode API keys in client code
- Use environment variables or secure token management
- Implement proper access controls
-
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
- Confirm real-time sync is enabled
- Check authentication status
- Verify proper event listeners are set up
- Optimize sync frequency
- Batch multiple operations
- Consider regional endpoints
Next Steps
Now that you have the basic integration working:- Explore advanced features in the Features Documentation
- Check platform-specific guides in the Platform Documentation
- Review the complete API Reference
- Join our Community for support and updates