Skip to main content

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

  1. Parse Request: Validate with Zod schemas
  2. Get Transaction: Fetch receipt from blockchain
  3. Extract Event: Find ConfidentialTransfer log
  4. Verify Recipient: Match transfer destination
  5. Verify Sender: Match decryption signature user
  6. Decrypt Amount: Use FHE relayer SDK
  7. Compare Amount: Check against requirements

Dependencies

PackagePurpose
honoWeb framework
ethersBlockchain interaction
@zama-fhe/relayer-sdkFHE decryption
zodSchema validation

Error Handling

StatusMeaning
200Payment valid
400Invalid payment
500Server error