Facilitator Service
Backend service for verifying FHE payments.
Production Service
A hosted facilitator is available for immediate use:
https://zama-facilitator.ultravioletadao.xyz
Hosted by Ultravioleta DAO. Supports Sepolia testnet.
Overview
The facilitator is a Hono-based API that:
- Extracts transfer events from blockchain
- Decrypts amounts using FHE relayer
- Validates payment requirements
Project Structure
x402-facilitator/
├── src/
│ ├── index.ts # Server entry point
│ ├── routes/
│ │ ├── health.ts # Health check
│ │ └── verify.ts # Payment verification
│ ├── services/
│ │ └── verification.ts # Core logic
│ ├── types/
│ │ └── index.ts # Zod schemas
│ └── utils/
│ └── config.ts # Configuration
└── package.json
Running
Development
cd packages/x402-facilitator
pnpm dev
Production
pnpm build
pnpm start
Endpoints
GET /
Service information.
{
"name": "X402 FHE Facilitator",
"version": "1.0.0",
"endpoints": {
"health": "GET /health",
"verify": "POST /verify"
}
}
GET /health
Health check.
{
"status": "ok",
"service": "x402-facilitator",
"version": "1.0.0",
"networks": ["fhevm-local", "sepolia"]
}
POST /verify
Verify FHE payment. See API Reference.
Verification Process
- Parse Request: Validate with Zod schemas
- Get Transaction: Fetch receipt from blockchain
- Extract Event: Find ConfidentialTransfer log
- Verify Recipient: Match transfer destination
- Verify Sender: Match decryption signature user
- Decrypt Amount: Use FHE relayer SDK
- Compare Amount: Check against requirements
Dependencies
| Package | Purpose |
|---|---|
hono | Web framework |
ethers | Blockchain interaction |
@zama-fhe/relayer-sdk | FHE decryption |
zod | Schema validation |
Error Handling
| Status | Meaning |
|---|---|
| 200 | Payment valid |
| 400 | Invalid payment |
| 500 | Server error |