x402-group-pay
Split one booking across N wallets — the 6-person dinner problem: pooled x402 contributions with signed receipts and funded proofs.

Pay in USDC on Base or Solana — your client picks the rail. Every 402 challenge lists both, and a pool records which rail funded each contribution.
Six people, one reservation, no shared card. An organizer creates a pool for the target amount; each participant — human at a checkout page or agent over HTTP — pays a fixed USDC share via x402 and gets a signed contribution receipt in the same response. When the last share lands, the pool emits a signed funded proof listing every contributor, ready to present to the merchant.
Why x402 for this
Group payments normally mean one person fronting the money and chasing five others, or a platform holding custodial balances behind accounts and API keys. With x402, each share is a standalone per-request USDC payment: no accounts, no stored cards, no settlement risk between friends — and agents can contribute on behalf of their humans with the exact same HTTP call a browser makes. Because the pool is denominated in USD and every contribution settles in USDC, the friend with a Base wallet and the friend with Phantom can fund the same pool without either of them bridging anything.
Quickstart
git clone https://github.com/nirholas/x402-group-pay && cd x402-group-pay
npm install
cp .env.example .env # pre-filled with the suite's receive addresses
npm run dev # server on http://localhost:4041
It boots with no configuration. To receive the funds yourself, set PAY_TO_ADDRESS (Base) and SOLANA_PAY_TO_ADDRESS (Solana) in .env — the server logs a note while the suite defaults are in use.
Then run the full paid flow with an agent wallet holding Base Sepolia USDC:
PRIVATE_KEY=0x... npm run client
Or open http://localhost:4041 for the human checkout demo (drop-in payment modal).
API
| Route | Price | What you get back |
|---|
POST /pools | $0.001 | Pool record + human/agent join links |
POST /pools/:id/pay | $0.01 (one share unit) | Signed contribution receipt with live progress |
GET /pools/:id | free | Live pool record |
GET /pools/:id/proof | free | Pending snapshot → signed funded proof once complete |
POST /verify | free | Signature check for any artifact issued here |
GET /healthz | free | Liveness + the rails this deployment accepts |
Each contributor pays on whichever rail they hold — the receipt records rail (evm/solana), the settlement network, the facilitator that settled it, and the transaction reference, and the pool keeps a running railBreakdown. The two rails use different facilitators (x402.org for Base, PayAI for Solana by default, since the reference facilitator does not settle Solana mainnet), so recording it per contribution matters for reconciliation. A pool's totalUsd is split into fixed SHARE_UNIT contributions (default $0.01). Members covering multiple units simply call /pay multiple times. Contributions to missing/closed pools still return a signed refund-claim instrument in the error body — payment never produces a silent side effect.
How x402 works — two rails, one flow
- Client calls a paid route → server responds
402 Payment Required with an accepts array holding both payment requirements: USDC on Base (EVM) and USDC on Solana (SVM), same price, same resource.
- Client picks the rail its wallet supports and authorizes exactly that amount — an EIP-3009 transfer authorization on Base, or a fee-sponsored SPL
transferChecked on Solana — then retries with the X-PAYMENT header.
- The server reads
network off the payload, selects the matching requirement, and verifies + settles through that rail's facilitator (x402.org for Base, PayAI for Solana by default).
- Server responds
200 with the artifact in-body and an X-PAYMENT-RESPONSE header carrying the settlement receipt (rail, network, facilitator, transaction, payer).
Solana buyers need no SOL: the facilitator's feePayer sponsors the network fee, so a USDC balance is enough. x402-fetch does steps 2–3 automatically — see examples/agent-client.ts and examples/curl.md.
Real backend / keys
Fully self-contained — no third-party data APIs. Env vars: