
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
x402-facilitator-proxy
Advanced tools
Multi-tenant payment gateway for API monetization with autonomous agent settlement on Base L2. Implements HTTP 402 protocol with USDC micropayments and programmatic fee routing.
A decentralized, autonomous payment infrastructure for API monetization on Base L2 with programmatic fee routing and agent-compatible settlement protocols.
The X402 Facilitator Proxy implements a complete multi-tenant payment gateway that enables merchants to monetize APIs through HTTP 402 "Payment Required" responses, while autonomous agents can seamlessly settle transactions using USDC on Base L2.
x402-facilitator-proxy/
├── src/ # Core Cloudflare Worker Engine
│ ├── index.ts # Main proxy gateway endpoint
│ └── backend/automation/
│ └── sweeper.ts # Automated fee collection
├── x402-client-sdk/ # Core Interface Rails
│ ├── src/
│ │ ├── client-library.ts # TypeScript SDK
│ │ └── mcp-server.ts # Model Context Protocol Server
│ ├── package.json # SDK dependencies
│ └── tsconfig.json # TypeScript configuration
└── templates/ # Integration Templates
├── express-middleware/
│ └── x402-guard.js # Merchant-Side API Gating
├── langchain-ts/
│ ├── agent.ts # TypeScript Agent Template
│ ├── package.json # LangChain dependencies
│ └── README.md # Setup instructions
└── crewai-python/
└── agent.py # Python Agent Template
The core backend (src/index.ts) operates as a serverless payment verification gateway deployed on Cloudflare's edge network:
https://x402-facilitator-proxy.seob5285.workers.dev/api/v1/verify-and-settle0x2E3DADfb314718849A93c49A78618E586c3b2C60Key Features:
The MCP server (x402-client-sdk/src/mcp-server.ts) provides a standardized interface for AI agents to interact with the payment system:
# Start the MCP server locally via stdio
npm run mcp:start
Protocol Features:
The Express middleware (templates/express-middleware/x402-guard.js) enables merchants to protect APIs with HTTP 402 challenges:
import { x402TollboothGuard } from './templates/express-middleware/x402-guard.js';
app.use('/api/premium', x402TollboothGuard("0.10", "0xYourWalletAddress"));
Middleware Behavior:
templates/langchain-ts/agent.ts)import { createPaymentAgent } from './templates/langchain-ts/agent.js';
const agent = await createPaymentAgent();
const result = await agent.invoke({
input: JSON.stringify({
agentPrivateKey: process.env.AGENT_PRIVATE_KEY,
developerWallet: "0x742d35Cc6297C24aE0E4838C4667C02693C4cB36",
amountUSD: "0.10"
})
});
templates/crewai-python/agent.py)from templates.crewai_python.agent import X402PaymentAgent
agent = X402PaymentAgent()
result = agent.process_payment({
"agent_private_key": os.getenv("AGENT_PRIVATE_KEY"),
"developer_wallet": "0x742d35Cc6297C24aE0E4838C4667C02693C4cB36",
"amount_usd": "0.10"
})
npm install
npm run deploy
cd x402-client-sdk
npm install
npm run mcp:start
# Copy the Express middleware to your project
cp templates/express-middleware/x402-guard.js your-project/middleware/
# Install in your Express app
import { x402TollboothGuard } from './middleware/x402-guard.js';
app.use('/api/protected', x402TollboothGuard("0.05", "0xYourWallet"));
# For TypeScript/LangChain agents
cd templates/langchain-ts
npm install
npm run dev
# For Python/CrewAI agents
cd templates/crewai-python
pip install -r requirements.txt
python agent.py
⚠️ NEVER HARDCODE PRIVATE KEYS IN REPOSITORY FILES
All sensitive credentials must be managed through secure environment variables:
# Set via Cloudflare Workers dashboard or wrangler
wrangler secret put FACILITATOR_PRIVATE_KEY
wrangler secret put PLATFORM_VAULT_ADDRESS
Create .env files for local testing:
# .env (root directory - for Cloudflare Worker development)
FACILITATOR_PRIVATE_KEY=0x1234567890abcdef...
PLATFORM_VAULT_ADDRESS=0x2E3DADfb314718849A93c49A78618E586c3b2C60
# Agent execution environments
AGENT_PRIVATE_KEY=0xabcdef1234567890...
OPENAI_API_KEY=sk-...
process.env.AGENT_PRIVATE_KEYos.getenv("AGENT_PRIVATE_KEY")https://x402-facilitator-proxy.seob5285.workers.dev/api/v1/verify-and-settle0x2E3DADfb314718849A93c49A78618E586c3b2C600x833589fCD6eDb6E08f4c7C32d4f71b54bda02913)graph TD
A[Agent API Call] --> B{HTTP 402?}
B -->|Yes| C[Parse Payment Requirements]
C --> D[Execute USDC Split Transfer]
D --> E[Submit to Proxy Gateway]
E --> F[Retry Original Request]
F --> G[Access Granted]
B -->|No| G
# Core proxy development
npm run dev # Start local development server
npm run deploy # Deploy to Cloudflare Workers
npm run cf-typegen # Generate Cloudflare types
# SDK development
cd x402-client-sdk
npm run build # Build TypeScript SDK
npm run mcp:start # Start MCP server
# Template testing
cd templates/langchain-ts
npm run dev # Test TypeScript agent
cd templates/crewai-python
python agent.py # Test Python agent
# Automated fee collection
npm run sweep # Execute fee sweeping automation
This project is licensed under the MIT License - enabling open-source innovation while maintaining platform sustainability through programmatic fee routing.
Built for the autonomous economy. Powered by Base L2. Secured by multi-tenant verification.
FAQs
Multi-tenant payment gateway for API monetization with autonomous agent settlement on Base L2. Implements HTTP 402 protocol with USDC micropayments and programmatic fee routing.
We found that x402-facilitator-proxy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.