Architecture Overview
Gx402 acts as a unified payment integration layer built on top of x402 — designed to bring seamless Web3 payments into game engines and web apps like Unity, Unreal, WebGL, Telegram Mini Apps, and Farcaster Mini Apps. Instead of building a new SDK, Gx402 currently uses existing x402 SDKs and connects them through a shared backend and middleware layer.This ensures consistent payments, authentication, and transaction handling across every platform.
Core Components
1. Platform Layer
Each platform (Unity, Unreal, WebGL, Telegram, etc.) integrates the x402 payment logic using custom wrappers or scripts.These wrappers handle:
- Player authentication
- In-game purchases or bets
- Sending transaction requests to middleware
2. Middleware Layer
A lightweight service that connects platform clients to the Gx402 backend.It helps handle:
- Platform-specific API differences
- Request normalization
- Security checks before server calls
Example: Unity and WebGL both send payment intents to /api/payments/initiate, which the middleware reformats before passing to the server.
3. Gx402 Server
Your main Express.js backend where:- Payment requests are validated
- User sessions are managed
- Calls are made to the x402 API
- Transactions are finalized and confirmed
4. x402 API
The foundation of all payment logic.It handles:
- Smart contract interactions
- Token transfers
- Receipt validation on-chain
5. Blockchain Layer
Finally, the blockchain network (e.g., Solana, Base, or Polygon) records every transaction initiated through x402.You don’t need to interact with it directly — Gx402 handles all the bridging and wallet logic for you.
Example Flow
- Player triggers a purchase in Unity (e.g., buys a game pass).
- Unity SDK wrapper sends a request → Middleware.
- Middleware validates and sends it to the Gx402 Server.
- Server processes and forwards to x402 API.
- x402 API finalizes the payment on-chain.
- Confirmation flows back through the same layers to the game.
Key Difference from x402
| Feature | x402 | Gx402 |
|---|---|---|
| SDK Type | Direct integration SDK | Middleware + Server bridge |
| Platform Coverage | Mostly web-based | Game engines + mini apps |
| Payment Flow | App → x402 → Blockchain | Platform → Middleware → Server → x402 → Blockchain |
| Customization | Limited | Fully customizable middleware and server logic |
| Deployment | Developer handles | Gx402 handles backend |
Future Plans
- Native Gx402 SDKs (
import { gx402 } from "gx402";) - Developer dashboard for payment tracking
- Custom tokens and NFTs integration
- Webhooks and realtime event streams
