Q402 (Sign-to-Pay) Protocol
The Q402 protocol introduces a universal sign-to-pay model for EVM chains. It replaces the traditional “approve → transfer → pay” pattern with a single signature flow that is:
Gasless for users (facilitator pays gas)
Permit2-compatible (no ERC-3009 token upgrades needed)
Policy-aware (spend limits, expiry, and whitelists)
Fully verifiable (on-chain receipts and logs)
This system forms the execution backbone of Quack AI’s AI Economy — powering both governance automation and day-to-day agent transactions.
For developers, the entire implementation — including core contracts, SDKs, middleware, and facilitator services — is open source here:
🔗 GitHub: github.com/quackai-labs/X402-BNB
Repository Structure
The x402 repository is organized into modular packages for flexible integration:
Directory / Package
Purpose
Tech Stack
/packages/core
Core SDK and client utilities for creating and signing x402 payment headers
TypeScript
/packages/facilitator
Standalone gas relay and settlement service for executing delegated transactions
Node.js / Docker
/packages/middleware-express
Express.js middleware for instant 402 payment validation
TypeScript
/packages/middleware-hono
Lightweight middleware for Hono-based APIs
TypeScript
/examples/bsc-testnet
Demo apps showing how to integrate x402 with APIs or dApps
JavaScript / Express
/docs
Architecture, standards, and deployment guides
Markdown
/specs
Core EIP-7702 implementation logic
Solidity + TS bindings
Each package is published under the @x402-bnb namespace and can be installed independently via pnpm or npm.
Core Developer Flow
Developers can use the x402 stack through three main integration paths:
Flow
Use Case
Entry Point
Client SDK
Apps or wallets generating sign-to-pay transactions
@x402-bnb/core
Server Middleware
APIs requiring payment validation or premium access
@x402-bnb/middleware-express or @x402-bnb/middleware-hono
Facilitator Service
Independent relay handling verification and gas sponsorship
@x402-bnb/facilitator
All flows support EIP-712 + EIP-7702 standards, use short-lived authorization tuples, and output a verifiable X-PAYMENT header that can be traced on-chain.
Example Use Cases
Scenario
Implementation Path
Gasless API access (e.g., premium endpoints)
Express middleware using @x402-bnb/middleware-express
DAO proposal execution with policy checks
Governance API + Facilitator
RWA payouts and treasury automation
Governance API + Q402 SDK
Subscription renewals for data agents
Facilitator + Permit2 integration
Merchant or marketplace settlement
Batch transactions via Facilitator Service
Each transaction includes a receipt hash linking signature → transaction → policy execution — providing a transparent audit trail for compliance and governance monitoring.
Last updated