Quick summary
Gx402 provides x402 integration examples and server middleware so teams can accept in-app payments (miniapps) and in-game purchases from engine builds (Unity/Unreal) running inside Farcaster or as standalone games. We are not shipping a proprietary SDK — instead, you get:- Engine-native examples
- A recommended Express middleware pattern
- Deployment notes for reliable x402 payments (
create → sign → confirm → finalize)
Prerequisites
- Node.js 18+ and a package manager (
pnpm,npm, oryarn) - Farcaster uses it’s In-App wallet connection so you don’t need any external wallet to connect
- x402 provider account & API keys (from your x402 provider)
- Unity (2021+) or Unreal (4.27+/5.x) for engine builds intended to run inside Farcaster or as standalone apps
- Basic knowledge of wallet signing (EIP-191 or EIP-712) and server-side HMAC/secret handling
We are still working on the flow of Unity Integrations for Miniapp, We will be providing the Unity WebGL
Integration Kit soon
Farcaster Miniapp Integration Flow
- Farcaster Miniapps provide native in-app wallet connections (e.g., Wagmi, Privy, or custom connectors).
- The Unity WebGL build runs seamlessly inside the Farcaster frame, maintaining wallet context and session continuity.
- All in-game and external transactions follow the same x402-compliant payment logic, powered by the Gx402 middleware.
- Gx402 acts as a facilitator layer, verifying Solana transactions and unlocking protected APIs or in-game assets post-payment.
- This architecture ensures cross-platform compatibility, allowing the same Unity game to run on Farcaster, Telegram, or browser-based miniapps with minimal code changes.
Farcaster Miniapp Intergration & Flow
- EVM
- Solana
EVM Flow
This guide explains how to integrate Unity WebGL games with Farcaster Miniapps.Your setup uses:
- Unity (WebGL) → gameplay & event triggers
- TypeScript Web Layer → bridge between Unity and Farcaster
- gx402 → connects Unity ↔ TypeScript/x402 payments
- Farcaster Evm Provider → signs & sends transactions inside Farcaster
Overview
- Rather than manually wiring every payment flow, x402 provides a payment-middleware + client wrapper that handles wallet connection, payment prompt, and protected API calls.
- The wallet integration is typically handled by an EVM-wallet library such as wagmi (or OnchainKit) — the miniapp template already includes this.
- The miniapp template auto-detects when it’s running inside Farcaster, and the frame SDK ensures the wallet and environment are set up appropriately.
- You protect routes via payment middleware. If a user calls a protected endpoint without paying, the server returns HTTP 402 (“Payment Required”) with details. Your client then triggers a wallet payment and retries the call with proof.
- Using a bridge between
Unity + Typescript + Mini-Appwe call x402 from our deployed server and Gx402
Unity Implementation
For now we will be using the same approach for build as of Unity Integration sectionWe will be providing the code snippet to connect the In-App wallet inside the game as repo is still under construction
