The Decentralized Facilitator for Agentic Payments
chaoschain-x402 is an early-stage TypeScript project in the AI payments / x402 ecosystem. It currently has 17 GitHub stars and 6 forks.
Powered by: ChaosChain · ERC-8004 · x402 · Chainlink CRE
ChaosChain-x402 replaces x402's centralized facilitator with a decentralized, BFT-verified runtime on Chainlink CRE.
Verify & settle agent payments with consensus proofs, attach ERC-8004 identity, and run it yourself or use our managed endpoints.
Current Status:
The Goal: Decentralized, trustless payment verification for the agent economy. The managed facilitator is our production MVP while we build the full CRE-based vision.
Managed Facilitator (Production - Available Now):
Decentralized Facilitator (In Development - The Vision):
# No installation needed! Just use the public endpoint:
# https://facilitator.chaoscha.in
# Test with Genesis Studio from https://github.com/ChaosChain/chaoschain-integrations:
export CC_FACILITATOR_URL=https://facilitator.chaoscha.in
python genesis_studio.py
git clone https://github.com/ChaosChain/chaoschain-x402
cd chaoschain-x402/http-bridge
# Install dependencies
npm install
# Configure environment (.env file)
cp .env.example .env
# Add your FACILITATOR_PRIVATE_KEY, RPC URLs, etc.
# Start in managed mode
npm run dev
The facilitator runs on :8402 and provides /verify and /settle endpoints for any x402 client.
The Problem with Centralized Facilitators:
Our Decentralized Solution (CRE-based):
OLD (Centralized)
Agent → Resource → [Facilitator Server] → Chain
• Single operator
• Opaque correctness
• Operational bottleneck
NEW (Decentralized with CRE)
Agent → Resource → [Workflow DON (N nodes)] → Chain
• BFT consensus on verify/settle
• Cryptographic proofs
• Run it yourself or use managed endpoints
Why It Matters:
See diagrams/architecture.txt for detailed flow diagrams.
| Component | Version | Status |
|---|---|---|
| x402 (spec) | v1 | Request/response shapes matched |
| ERC-8004 | v1.0 | Identity attached via ChaosChain SDK |
| CRE | TS SDK 0.0.9-alpha | Simulate mode now; DON deployment later |
| Chains | Base, Ethereum | Sepolia testnets + mainnets ready |
# Clone repo
git clone https://github.com/ChaosChain/chaoschain-x402.git
cd chaoschain-x402
# Start everything with Docker Compose
docker-compose up http-bridge
# In another terminal, run demo
docker-compose --profile demo up ts-demo
See docs/DOCKER.md for full Docker guide.
Prerequisites:
Steps:
# 1. Clone repo
git clone https://github.com/ChaosChain/chaoschain-x402.git
cd chaoschain-x402
# 2. Start HTTP bridge
cd http-bridge && bun install && bun run dev
# 3. Run demo (in new terminal)
cd examples/ts-demo && bun install && bun run dev
# or: cd examples/py-demo && pip install -r requirements.txt && python demo.py
Expected output:
╔═══════════════════════════════════════════════════════════╗
║ ChaosChain x402 Decentralized Facilitator Bridge ║
╚═══════════════════════════════════════════════════════════╝
🚀 Server listening on http://localhost:8402
📋 CRE Workflow Ready
Test the actual CRE workflow locally:
cd workflows/x402-facilitator && bun install && cd ../..
cre workflow simulate x402-facilitator --target local-simulation
Note: The HTTP bridge provides a stable API without requiring CRE CLI.
ChaosChain provides a production-ready managed facilitator at https://facilitator.chaoscha.in that handles all payment verification and settlement complexity.
transferWithAuthorization - we never hold your fundsapprove() transactionAll API responses include both human strings (e.g., "1.00" USDC) and base unit strings (e.g., "1000000" for 6-decimal tokens). Use whichever is convenient; settlement logic uses base units.
Example response:
{
"amount": { "human": "1.00", "base": "1000000", "symbol": "USDC", "decimals": 6 },
"fee": { "human": "0.01", "base": "10000", "bps": 100 },
"net": { "human": "0.99", "base": "990000" }
}
The ChaosChain facilitator URL is https://facilitator.chaoscha.in.
That's it. No signup, no API keys, no complexity. Every payment automatically builds your agent's on-chain reputation via ERC-8004.
With ChaosChain SDK (Recommended):
import { ChaosChainSDK } from '@chaoschain/sdk';
const sdk = new ChaosChainSDK({
facilitatorUrl: 'https://facilitator.chaoscha.in',
agentId: '8004#123', // Optional: ERC-8004 tokenId for reputation
});
// Payments automatically route through facilitator
With Raw HTTP:
curl -X POST https://facilitator.chaoscha.in/verify \
-H 'Content-Type: application/json' \
-d '{
"x402Version": 1,
"paymentHeader": {
"sender": "0xPayerAddress",
"nonce": "unique_nonce_123",
"validAfter": "2025-10-29T00:00:00Z",
"validBefore": "2025-10-29T01:00:00Z"
},
"paymentRequirements": {
"scheme": "exact",
"network": "base-sepolia",
"maxAmountRequired": "10.00",
"payTo": "0xMerchantAddress",
"asset": "usdc",
"resource": "/api/service"
}
}'
Response:
{
"isValid": true,
"feeAmount": "100000",
"netAmount": "9900000",
"feeBps": 100,
"consensusProof": "0xabc123...",
"timestamp": 1730160000
}
Simple flat fee: 1% on all transactions
Example: 10 USDC payment
Want to run your own facilitator? Set these environment variables:
# Facilitator Configuration
FACILITATOR_MODE=managed
DEFAULT_CHAIN=base-sepolia
# Fee Configuration
FEE_BPS_DEFAULT=100 # 1%
TREASURY_ADDRESS=0xYourTreasuryAddress
# RPC Endpoints
BASE_SEPOLIA_RPC_URL=https://sepolia.base.org
ETHEREUM_SEPOLIA_RPC_URL=https://ethereum-sepolia.blockpi.network/v1/rpc/public
# Hot Wallet
FACILITATOR_PRIVATE_KEY=0xYourPrivateKey
# ChaosChain ERC-8004 Integration (automatic when using SDK)
CHAOSCHAIN_ENABLED=true
VALIDATION_REGISTRY_ADDRESS=0xRegistryAddress
# Supabase (for transaction tracking)
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_KEY=your-service-key
Check facilitator health:
curl https://facilitator.chaoscha.in/health
{
"healthy": true,
"checks": {
"supabase": true,
"rpcBaseSepolia": true,
"gasBalance": "0.5",
"gasBalanceHealthy": true,
"usdcBalance": "1000.0",
"rpcLatencyMs": 120,
"blockLag": 2
}
}
Status page: https://status.facilitator.chaoscha.in
Want to monetize your AI agent services? See our merchant guide:
→ Merchant Guide: Selling Services with x402
Quick overview:
402 Payment Required with payment requirementstransferWithAuthorizationExternal SDK integration specifications:
| Feature | Managed (Production) | Decentralized (Beta) |
|---|---|---|
| Deployment | Hosted by ChaosChain | Self-hosted or CRE DON |
| Settlement | EIP-3009 on-chain | CRE workflow consensus |
| Fees | 1% flat fee | Gas only (if self-hosted) |
| Setup | Zero - just use the URL | Requires CRE deployment |
| Support | Community Discord | Community Discord |
| Identity (ERC-8004) | Automatic when using SDK | Automatic when using SDK |
| Best for | Production apps, merchants | Maximum trust-minimization |
Recommendation: Start with managed (https://facilitator.chaoscha.in) for immediate production use.
chaoschain-x402/
├── workflows/x402-facilitator/ # CRE workflow (verify + settle handlers)
├── http-bridge/ # REST API server (Fastify)
├── clients/
│ ├── ts/ # @chaoschain/x402-client (TypeScript)
│ └── py/ # chaoschain-x402-client (Python)
├── examples/
│ ├── ts-demo/ # TypeScript demo
│ └── py-demo/ # Python demo
├── diagrams/ # Architecture diagrams
├── project.yaml # CRE project configuration
└── README.md # This file
The HTTP bridge implements the x402 facilitator API spec with full consensus verification flow.
| Variable | Default | Description |
|---|---|---|
PORT |
8402 |
HTTP bridge port |
CRE_MODE |
simulate |
simulate | remote |
CRE_WORKFLOW_URL |
— | Remote CRE endpoint (required for remote mode) |
LOG_LEVEL |
info |
debug | info | warn | error |
GET /Health check and service information.
Example:
curl -s http://localhost:8402/ | jq
Response:
{
"service": "ChaosChain x402 Decentralized Facilitator",
"version": "0.1.0",
"mode": "simulate",
"endpoints": {
"verify": "POST /verify",
"settle": "POST /settle",
"supported": "GET /supported"
}
}
GET /supportedList supported payment schemes and networks (per x402 spec).
Example:
curl -s http://localhost:8402/supported | jq
Response:
{
"kinds": [
{ "scheme": "exact", "network": "base-sepolia" },
{ "scheme": "exact", "network": "ethereum-sepolia" },
{ "scheme": "exact", "network": "base-mainnet" },
{ "scheme": "exact", "network": "ethereum-mainnet" }
]
}
POST /verifyVerify an x402 payment via decentralized consensus.
Example:
curl -X POST http://localhost:8402/verify \
-H 'Content-Type: application/json' \
-d '{
"x402Version": 1,
"paymentHeader": "base64_encoded_payment_payload",
"paymentRequirements": {
"scheme": "exact",
"network": "base-sepolia",
"maxAmountRequired": "1000000",
"payTo": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0",
"asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"resource": "/api/weather"
}
}' | jq
Response:
{
"isValid": true,
"invalidReason": null,
"consensusProof": "0x307837343264333543633636333433303353333233323...",
"reportId": "rep_1730845234567",
"timestamp": 1730845234567
}
POST /settleSettle an x402 payment via decentralized consensus.
Example:
curl -X POST http://localhost:8402/settle \
-H 'Content-Type: application/json' \
-d '{
"x402Version": 1,
"paymentHeader": "base64_encoded_payment_payload",
"paymentRequirements": {
"scheme": "exact",
"network": "base-sepolia",
"maxAmountRequired": "1000000",
"payTo": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0",
"asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"resource": "/api/weather"
}
}' | jq
Response:
{
"success": true,
"error": null,
"txHash": "0x307837343264333543633636333433303353333233323...",
"networkId": "base-sepolia",
"consensusProof": "0x30783734326433354363636333343330335333323332...",
"timestamp": 1730845234567
}
OpenAPI Spec: See docs/openapi.yaml for complete API specification.
Decentralized version currently runs in local development mode:
This allows public development and testing without requiring access to the CRE private alpha.
When Chainlink CRE becomes publicly available, swap to production mode:
See workflows/x402-facilitator/README.md for details on upgrading.
The facilitator is decentralized via Chainlink CRE:
See diagrams/architecture.txt for the detailed flow.
The facilitator supports multiple chains with different settlement methods:
| Chain | Network ID | Token | Settlement Method | Status |
|---|---|---|---|---|
| Base Sepolia | base-sepolia |
USDC | EIP-3009 (gasless) | ✅ Supported |
| Ethereum Sepolia | ethereum-sepolia |
USDC | EIP-3009 (gasless) | ✅ Supported |
| Base Mainnet | base-mainnet |
USDC | EIP-3009 (gasless) | ✅ Supported |
| Ethereum Mainnet | ethereum-mainnet |
USDC | EIP-3009 (gasless) | ✅ Supported |
| 0G Mainnet | 0g-mainnet |
W0G | Relayer (requires approval) | ✅ Supported |
Settlement Methods:
Add new chains by extending the CHAIN_CONFIG and TOKEN_ADDRESSES in settlement.ts.
| Tier | Description | Pricing Model |
|---|---|---|
| Open Source | Self-hosted CRE workflows | Free |
| Managed Facilitator | SLA-backed endpoints hosted by ChaosChain | % per transaction |
| Enterprise Plan | Private facilitator cluster + audit logs | Monthly SaaS |
Protocol fees can be routed to the ChaosChain Treasury for validator rewards and future staking incentives.
# HTTP Bridge
cd http-bridge
bun install
bun run build
# TypeScript Client
cd ../clients/ts
bun install
bun run build
# Python Client
cd ../clients/py
pip install -e .
# TypeScript
cd clients/ts
bun run typecheck
# Python
cd clients/py
pytest
Vision: Build the first truly decentralized x402 facilitator with BFT consensus, replacing centralized payment verification with cryptographic proofs.
transferWithAuthorizationfacilitator.chaoscha.inWe welcome contributions! See CONTRIBUTING.md for details.
Key Areas for Contribution:
upto)ChaosChain — builders of the Triple-Verified Stack for trustless AI commerce.
Maintained by the same team behind:
License: MIT
Contact: [email protected]
"Decentralizing the economic heartbeat of the agentic web."
Built with support from:
This project is licensed under the MIT License - see the LICENSE file for details.
Status: 🟢 Production (Managed) | Active Development (Decentralized)