Demonstrates how PEAC receipts work with x402 HTTP 402 payment flows.
Live demo: x402.peacprotocol.org | Visual demo repo
- Client requests a protected resource (no receipt)
- Server returns 402 with x402 v2 payment requirements
- Client pays via x402 (Base/USDC in this example)
- Server issues a signed PEAC receipt with x402 evidence
- Client verifies the receipt offline
+------------------+ +------------------+
| Client | | Server |
+------------------+ +------------------+
| |
| 1. GET /resource |
|----------------------->|
| |
| 2. 402 Payment-Required|
| (x402 v2 headers) |
|<-----------------------|
| |
| 3. Pay via x402 |
| (Base/USDC) |
|----------------------->|
| |
| 4. 200 OK |
| PEAC-Receipt: <jws> |
|<-----------------------|
| |
| 5. Verify offline |
| (Ed25519 JWS) |
+------------------+ +------------------+
This example uses x402 v2 header format:
HTTP/1.1 402 Payment Required
Content-Type: application/problem+json
Payment-Required: {"network":"eip155:8453","asset":"USDC","amount":"50","recipient":"0x...","resource":"..."}
PEAC-Issuer: https://payment.example.comThe Payment-Required header (v2) replaces the X-PAYMENT header from v1.
{
"typ": "interaction-record+jwt",
"iss": "https://payment.example.com",
"aud": "https://api.example.com/premium/data",
"amt": 50,
"cur": "USD",
"payment": {
"rail": "x402",
"asset": "USDC",
"env": "live",
"reference": "x402_1703001234567",
"evidence": {
"network": "eip155:8453",
"tx_hash": "0xabc123...",
"recipient": "0x1234...",
"x402_version": "v2"
}
}
}From the repository root:
pnpm install
pnpm buildcd examples/x402-node-server
pnpm demoExpected output:
=== x402 + PEAC Integration Demo ===
Resource: https://api.example.com/premium/data
Network: eip155:8453
Price: $0.50 USDC
1. Client requests protected resource...
-> 402 Payment Required
-> Network: eip155:8453
-> Asset: USDC
-> Amount: 50
2. Client pays via x402...
-> Payment confirmed
-> PEAC receipt issued (xxx chars)
3. Client retries with PEAC-Receipt header...
-> 200 OK - Access granted!
-> Data: {"data":"Premium content unlocked via x402 payment","accessedAt":"..."}
4. Verify receipt offline...
-> Receipt claims:
iss: https://payment.example.com
aud: https://api.example.com/premium/data
amt: 50 USD
rail: x402
network: eip155:8453
tx_hash: 0x...
=== Demo Complete ===
- x402 is the payment rail (Base/USDC, Solana, etc.)
- PEAC is the receipt layer (cryptographic proof of payment)
Together they provide:
- Instant payments via crypto rails
- Offline-verifiable receipts
- Audit trail with payment evidence
| Network | CAIP-2 ID |
|---|---|
| Base Mainnet | eip155:8453 |
| Base Sepolia | eip155:84532 |
| Solana Mainnet | solana:mainnet |
| Solana Devnet | solana:devnet |
Clients can verify receipts:
- At request time - Server verifies before granting access
- Offline - Client verifies signature without network calls
- Later - Audit systems can verify historical receipts
For production x402 + PEAC integration:
- Server-side: Use
@peac/rails-x402adapter - Discovery: Publish
/.well-known/peac.txtwith payment terms - x402 SDK: Use Coinbase x402 SDK for payment handling
See the x402 ecosystem for compatible tools and services.
This example simulates:
- x402 payment confirmation
- PEAC receipt issuance
- Offline verification
No network calls or secrets required.