Skip to main content

Quick summary

Gx402 provides x402-integration examples and server middleware so teams can accept in-app payments (mini-apps) and in-game purchases from engine builds on Base network.
By running your Unity or Unreal WebGL build inside a Base Mini-App or supporting Base-connected wallets, you can apply the same
create → sign → confirm → finalize logic with minimal changes.

Prerequisites

  • Node.js 18+ and a package manager (pnpm, npm, or yarn)
  • A Base Mini-App environment (via Base OnchainKit or MiniKit)
  • x402 provider account & API keys (for Gx402 middleware)
  • Unity (2021+) or Unreal (4.27+/5.x) for engine builds intended to run inside a Base Mini-App
  • Basic wallet signing knowledge (EVM / Base network) and server-side HMAC/secret logic for verification

We are still working on the flow of Unity Integrations for Miniapp, We will be providing the Unity WebGL Integration Kit soon

High-Level Flow (Base Mini-App + Gx402)

  1. Launch & Context
    • Your Mini-App runs inside the Base container using OnchainKit/MiniKit.
    • Wallet context is injected, enabling seamless transaction handling on Base.
  2. Connect Wallet / Session
    • Your Unity/WebGL or web client connects via the Base wallet provider.
    • Once connected, the wallet address and session state are stored.
  3. Create Payment Requirements (Gx402)
    • The frontend calls your backend to create a paymentRequirements object using Gx402.
    • If no valid X-402-Payment header exists, the backend returns a 402 challenge.
  4. Sign & Send Transaction
    • The client (Unity/web) builds a USDC on Base transaction and requests user signature.
    • On confirmation, you receive a txSignature (TX hash).
  5. Verify & Unlock
    • Client sends X-402-Payment: <txSignature> to backend.
    • Backend verifies the transaction and unlocks the resource if valid.
  6. Access Granted
    • Client receives a 200 OK response.
    • Unity updates UI → ✅ “Payment Verified — Access Granted!”

Example Server Snippet (Next.js / Express style)

Folder Structure (Base Mini-App Web + Unity WebGL build)