x402 payment protocol implementation in .NET - enable AI agents to pay for your APIs with USDC micropayments
AgenticCommerce is an early-stage HTML project in the AI payments / x402 ecosystem, focused on agent-economy, ai-agents, arc-blockchain, arcos. It currently has 2 GitHub stars and 0 forks, and sits alongside related tools like crewai-x402, langchain-x402, piprail, x402-pay, agentrails-copilot-actions, p402-protocol.
The orchestration layer between AI agents and the financial system
www.agentrails.io | Documentation | Blog | Microsoft Marketplace
Agent-agnostic. Model-agnostic. Enterprise-ready.
AgentRails connects any AI agent to payment infrastructure with the budget controls, transaction logging, and compliance that businesses demand.
As AI agents proliferate, they need to transact. But:
No one owns the bottleneck between intelligent agents and the financial system.
AgentRails is payment orchestration infrastructure for the agentic economy:
| What We Do | What We Don't Do |
|---|---|
| Connect agents to financial rails | Build AI models |
| Enforce budget policies | Route to different LLMs |
| Log every transaction | Compete with agent frameworks |
| Provide audit trails | Lock you into our stack |
"The value is not in the application. It is in the connective tissue between applications, data, and decisions."
— Jordi Visser, "Palantir as Signal"
AgentRails is the connective tissue between AI agents and the financial system.
| Old Model (SaaS) | New Model (Agentic) |
|---|---|
| Per-seat pricing | Per-transaction pricing |
| Humans use software | Agents use APIs |
| Monthly subscriptions | Micropayments per action |
| $50/seat/month | $0.001 per API call |
AgentRails provides the payment rails for this new model via the x402 protocol.
Once agents are wired to AgentRails:
Works with any AI agent, any framework, any model:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Any AI Agent │ │ AgentRails │ │ Financial │
│ │ │ │ │ System │
│ - GPT-4o │────▶│ - Orchestrate │────▶│ │
│ - Claude │ │ - Authorize │ │ - USDC │
│ - Llama │ │ - Log │ │ - Arc/Base │
│ - Custom │ │ - Settle │ │ - Banks (soon) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ Governance │
│ │
│ - Budgets │
│ - Policies │
│ - Audit Logs │
└─────────────────┘
┌─────────────┐ ┌─────────────┐
│ AI Agent │ │ API Server │
└──────┬──────┘ └──────┬──────┘
│ │
│ 1. GET /api/protected/data │
│ ─────────────────────────────────────────► │
│ │
│ 2. 402 Payment Required │
│ X-PAYMENT-REQUIRED: {amount, payTo} │
│ ◄───────────────────────────────────────── │
│ │
│ 3. AgentRails signs EIP-3009 auth │
│ (budget check + policy validation) │
│ │
│ 4. GET /api/protected/data │
│ X-PAYMENT: {signed_authorization} │
│ ─────────────────────────────────────────► │
│ │
│ 5. Verify → Settle → Log │
│ │
│ 6. 200 OK + X-PAYMENT-RESPONSE │
│ {data + transactionHash} │
│ ◄───────────────────────────────────────── │
git clone https://github.com/agentrails/agentrails.git
cd agentrails
docker run --name agentrails-db \
-e POSTGRES_PASSWORD=dev_password_change_in_prod \
-e POSTGRES_DB=agentrails \
-p 5432:5432 \
-d postgres:16
cd src/AgenticCommerce.API
# Circle Configuration (for blockchain settlement)
dotnet user-secrets set "Circle:ApiKey" "your-circle-api-key"
dotnet user-secrets set "Circle:EntitySecret" "your-entity-secret-hex"
dotnet user-secrets set "Circle:WalletAddress" "0xYourWalletAddress"
dotnet user-secrets set "Circle:WalletId" "your-wallet-id"
# Optional: OpenAI for built-in agent reasoning
dotnet user-secrets set "OpenAI:ApiKey" "your-openai-api-key"
dotnet run --launch-profile https
Navigate to https://localhost:7098/swagger to explore the API.
[X402Payment(0.01, Description = "Premium analysis")]
[HttpGet("analysis")]
public IActionResult Analysis()
{
var payer = HttpContext.GetX402Payer();
return Ok(new {
data = "Premium content",
paidBy = payer
});
}
That's it. Your endpoint now requires $0.01 USDC per request. AgentRails handles verification, settlement, and logging automatically.
| Endpoint | Description |
|---|---|
POST /api/agents |
Create agent with budget |
POST /api/agents/{id}/run |
Execute autonomous task |
POST /api/agents/{id}/purchase |
Direct payment execution |
GET /api/agents/{id} |
Get agent state |
| Endpoint | Description |
|---|---|
GET /api/x402/protected/analysis |
Example paid endpoint ($0.01) |
GET /api/x402/protected/data |
Micropayment endpoint ($0.001) |
POST /api/x402/facilitator/verify |
Verify payment signatures |
POST /api/x402/facilitator/settle |
Execute on-chain settlement |
GET /api/x402/payments |
Payment history |
GET /api/x402/stats |
Analytics |
┌─────────────────────────────────────────────────────────────┐
│ AgentRails.API │
│ (REST Controllers + x402 Middleware) │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ ORCHESTRATION LAYER │ │
│ ├─────────────────────────────────────────────────────┤ │
│ │ • Agent lifecycle management │ │
│ │ • Budget enforcement │ │
│ │ • Policy evaluation │ │
│ │ • x402 payment handling │ │
│ │ • Transaction logging │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ ┌──────────────────┐ ┌────────────────────────────┐ │
│ │ Blockchain │ │ Persistence │ │
│ │ • Circle DCW │ │ • Agents │ │
│ │ • Arc Network │ │ • Transactions │ │
│ │ • EVM Chains │ │ • x402 Payments │ │
│ │ • EIP-3009 │ │ • Audit Logs │ │
│ └──────────────────┘ └────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
| Network | Chain ID | Environment |
|---|---|---|
| arc-testnet | 5042002 | Development |
| arc-mainnet | TBD | Production |
| base-sepolia | 84532 | Development |
| base-mainnet | 8453 | Production |
| ethereum-sepolia | 11155111 | Development |
| ethereum-mainnet | 1 | Production |
The orchestration layer for agent payments — like Palantir connects AI to enterprise data, AgentRails connects AI agents to financial rails.
| Layer | Who Wins | Example |
|---|---|---|
| AI Models | Commoditizing | OpenAI, Anthropic, open source |
| Agent Frameworks | Fragmented | LangChain, CrewAI, Semantic Kernel |
| Model Routers | Niche | ClawRouter |
| Payment Orchestration | Winner-take-most | AgentRails |
For LLM cost optimization, we recommend solutions like ClawRouter. AgentRails focuses on what happens after your agent decides to act—executing compliant, auditable transactions.
For regulated industries requiring advanced governance:
Contact contact@agentrails.io for licensing.
We welcome contributions! See CONTRIBUTING.md for guidelines.
MIT License - See LICENSE for details.
Built with:
AgentRails: The connective tissue between AI agents and the financial system.
Built for the agentic economy.
CrewAI integration for x402 payments - autonomous agent crews that pay for APIs with USDC
LangChain integration for x402 payments - let AI agents pay for APIs with USDC automatically
x402 (HTTP 402 Payment Required) SDK + MCP server: let any API charge for itself and any AI agent pay for itself, USDC & stablecoins across EVM, Solana & 8 more chain families, in a couple of lines. Backendless, no fee, self-custodial, paid straight to your wallet. TypeScript, MIT.
Open-source x402 payment processor for AI agents. Sub-400ms settlement on Solana + 7 EVM chains. Let LLMs pay for APIs programmatically with USDC. npm: nory-x402
Copilot Studio action definitions for AgentRails x402 payment infrastructure. Import into Microsoft Copilot Studio for natural-language agent management and FinanceOps in Teams.
P402 Payment Protocol
The agent-native LLM router for autonomous agents. 55+ models (8 free), <1ms local routing, USDC payments on Base & Solana via x402.
The AI agent with a wallet — spends USDC autonomously to get real work done. Apache-2.0, TypeScript.
DePIN for Vintage Hardware — Proof-of-Antiquity blockchain where old machines outmine new ones. AI-powered hardware fingerprinting, 15+ CPU architectures, Solana bridge (wRTC). $0 VC.
🚀 Curated list of x402 resources: HTTP 402 Payment Required protocol for blockchain payments, crypto micropayments, AI agents, API monetization. Includes SDKs (TypeScript, Python, Rust), examples, facilitators (Coinbase, Cloudflare), MCP integration, tutorials. Accept USDC payments with one line of code. Perfect for AI agent economy.
Client SDK for the Vybe x402 API. Pay-per-call USDC over HTTP and prepaid-credit WebSocket streaming for Vybe's Solana analytics API. Built for AI agents.
The financial operating system for AI agents. A single HTTP client that intercepts '402 Payment Required', routes across x402, L402, and MPP, persists credentials as recoverable assets, enforces per-envelope budgets, and emits a structured trace.