AI agents that research, decide, and execute USDC payments autonomously on Arc blockchain
Built with Circle Developer Controlled Wallets, Arc blockchain, and OpenAI GPT-4o for fully autonomous commerce.
Autonomous AI agents that can:
- Research options using built-in knowledge bases
- Make informed decisions via GPT-4o reasoning
- Execute USDC payments on Arc blockchain
- Manage budgets with constraint enforcement
- Settle instantly with sub-second finality
- Persist forever with PostgreSQL database
- Pay for APIs using x402 protocol (HTTP 402 payments)
No human intervention required. Built for the institutional settlement model.
This platform implements the x402 protocol - an HTTP payment standard by Coinbase/Cloudflare that enables AI agents to pay for API access using cryptocurrency.
┌─────────────┐ ┌─────────────┐
│ AI Agent │ │ API Server │
└──────┬──────┘ └──────┬──────┘
│ │
│ 1. GET /api/x402/protected/analysis │
│ ─────────────────────────────────────────► │
│ │
│ 2. 402 Payment Required │
│ X-PAYMENT-REQUIRED: <base64> │
│ ◄───────────────────────────────────────── │
│ │
│ 3. Sign EIP-3009 authorization │
│ (transferWithAuthorization) │
│ │
│ 4. GET /api/x402/protected/analysis │
│ X-PAYMENT: <signed_payload> │
│ ─────────────────────────────────────────► │
│ │
│ 5. Verify signature, settle on-chain │
│ │
│ 6. 200 OK + X-PAYMENT-RESPONSE │
│ { paid content } │
│ ◄───────────────────────────────────────── │
| Endpoint | Description |
|---|---|
GET /api/x402/protected/analysis |
Paid endpoint - $0.01 USDC per request |
GET /api/x402/protected/data |
Micropayment endpoint - $0.001 USDC |
GET /api/x402/pricing |
Get pricing info for all endpoints |
POST /api/x402/facilitator/verify |
Verify payment payloads |
POST /api/x402/facilitator/settle |
Execute payment settlement on-chain |
GET /api/x402/payments |
Payment history with filtering |
GET /api/x402/stats |
Aggregated payment statistics |
Step 1: Request paid resource (no payment)
curl https://your-api.com/api/x402/protected/analysis
# Response: 402 Payment Required
# Header: X-PAYMENT-REQUIRED: eyJ4NDAyVmVyc2lvbiI6Miwi...
{
"x402Version": 2,
"accepts": [{
"scheme": "exact",
"network": "arc-testnet",
"maxAmountRequired": "10000",
"resource": "/api/x402/protected/analysis",
"description": "AI Analysis API - $0.01 per request",
"payTo": "0x6255d8dd3f84ec460fc8b07db58ab06384a2f487"
}]
}Step 2: Agent signs payment and retries
curl https://your-api.com/api/x402/protected/analysis \
-H "X-PAYMENT: eyJ4NDAyVmVyc2lvbiI6Miwic2NoZW1lIjoi..."
# Response: 200 OK
# Header: X-PAYMENT-RESPONSE: {"success":true,"transactionHash":"..."}
{
"result": "AI analysis complete!",
"analysis": "Premium AI-powered analysis data",
"costUsdc": 0.01,
"transactionHash": "58026c24-3874-55e9-8e76-6ab6d50fb7d8"
}| Endpoint | Description |
|---|---|
GET /api/x402/test/wallet-status |
Check Circle wallet configuration |
GET /api/x402/test/generate-payload |
Generate mock test payloads |
GET /api/x402/test/generate-signed-payload |
Generate real EIP-712 signed payload (verifiable) |
POST /api/x402/test/execute-payment |
Execute real payment on Arc testnet |
All x402 payments are persisted to PostgreSQL:
SELECT * FROM x402_payments;
-- Example record:
-- payment_id: x402_abc123_639039159723714890
-- resource: /api/x402/protected/analysis
-- network: arc-testnet
-- amount_usdc: 0.01
-- payer_address: 0xAgent...
-- recipient_address: 0xMerchant...
-- transaction_hash: 58026c24-3874-55e9-8e76-6ab6d50fb7d8
-- status: Settled
-- created_at: 2026-01-13T15:46:12Z- AI-powered research and analysis
- Budget validation and enforcement
- Risk assessment and strategy planning
- Multi-step reasoning with tool use
- Developer Controlled Wallets for agent custody
- Native USDC settlement on Arc blockchain
- Sub-second transaction finality (<1s)
- Predictable USDC-based gas fees
- No volatile gas tokens required
- Spec-compliant V2 implementation
- Payment verification and settlement
- EIP-3009 transferWithAuthorization support
- Multi-network support (Arc, Base, Ethereum)
- Payment history and analytics
- PostgreSQL persistence with EF Core
- Agents survive application restarts
- Complete transaction history tracking
- x402 payment audit trail
- Relational data model with migrations
- .NET 8.0 SDK
- Docker Desktop (for PostgreSQL)
- Circle Developer Account
- OpenAI API Key
git clone https://github.com/kmatthewsio/AgenticCommerce.git
cd AgenticCommercedocker run --name agenticcommerce-db \
-e POSTGRES_PASSWORD=dev_password_change_in_prod \
-e POSTGRES_DB=agenticcommerce \
-p 5432:5432 \
-d postgres:16Option A: User Secrets (Recommended for Development)
cd src/AgenticCommerce.API
# Circle Configuration
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"
# OpenAI Configuration
dotnet user-secrets set "OpenAI:ApiKey" "your-openai-api-key"
dotnet user-secrets set "OpenAI:Model" "gpt-4o"Option B: Environment Variables (Production)
# Use double underscore for nested config
export Circle__ApiKey="your-circle-api-key"
export Circle__EntitySecret="your-entity-secret-hex"
export Circle__WalletAddress="0xYourWalletAddress"
export Circle__WalletId="your-wallet-id"
export OpenAI__ApiKey="your-openai-api-key"cd src/AgenticCommerce.API
dotnet run --launch-profile httpsNavigate to https://localhost:7098/swagger to explore the API.
┌─────────────────────────────────────────────────────────────┐
│ AgenticCommerce.API │
│ (REST API + Swagger + x402 Controllers) │
└─────────────────────────┬───────────────────────────────────┘
│
┌─────────────────────────▼───────────────────────────────────┐
│ AgenticCommerce.Infrastructure │
│ │
│ ┌──────────────────┐ ┌────────────────────────────────┐ │
│ │ Agent Service │ │ x402 Payment Service │ │
│ │ • Lifecycle │ │ • Verify payments │ │
│ │ • AI Execution │ │ • Settle on-chain │ │
│ │ • Budget Mgmt │ │ • Payment persistence │ │
│ └──────────────────┘ └────────────────────────────────┘ │
│ │
│ ┌──────────────────┐ ┌────────────────────────────────┐ │
│ │ Circle/Arc │ │ Database (EF Core) │ │
│ │ • ArcClient │ │ • Agents │ │
│ │ • USDC Transfers│ │ • Transactions │ │
│ │ • Wallet API │ │ • x402 Payments │ │
│ └──────────────────┘ └────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────▼───────────────────────────────────┐
│ AgenticCommerce.Core │
│ (Domain Models + Interfaces + x402 Spec) │
└─────────────────────────────────────────────────────────────┘
- Backend: ASP.NET Core 8.0 / C#
- Database: PostgreSQL 16 + Entity Framework Core 8
- Blockchain: Circle Developer Controlled Wallets + Arc (Chain ID: 5042002)
- AI: OpenAI GPT-4o + Microsoft Semantic Kernel 1.30.0
- Payments: x402 V2 Protocol (EIP-3009/EIP-712)
- Crypto: Nethereum.Signer for ECDSA signatures
- API: REST with OpenAPI/Swagger documentation
Monetize your APIs with micropayments. AI agents pay per request automatically.
AI agents that research vendors, compare pricing, and execute purchases within approved budgets.
Offer payment verification and settlement as a service for other API providers.
Agents that manage corporate funds, execute payments, and maintain budget compliance.
- Circle API integration
- Arc blockchain settlement
- AI agent reasoning (GPT-4o)
- Autonomous execution
- Budget management
- PostgreSQL with Docker
- Entity Framework Core migrations
- Agent persistence
- Transaction history tracking
- Spec-compliant implementation
- Payment verification (EIP-3009/EIP-712)
- On-chain settlement via Arc
- Facilitator endpoints (verify/settle)
- Payment persistence & analytics
- Test endpoints for development
- Real EIP-712 signature generation & verification
- Stripe payment integration
- API key provisioning
- Organization setup
Enterprise extensions available: Policy engine (spend limits, rate limiting, destination controls), admin dashboard, audit logging, multi-tenant isolation, and hybrid fiat/crypto billing.
Govern agent spend at scale. Prevent budget overruns. Comply with enterprise policies.
Contact sales@agentrails.io for licensing.
- Policy engine (spending limits, approval workflows)
- Admin dashboard
- Audit logging
- Advanced multi-tenancy
- Agent detects 402 responses
- Automatic payment signing
- Full autonomous pay-per-call
- API keys encrypted at rest
- RSA-OAEP-SHA256 for Circle authentication
- Budget constraints enforced cryptographically
- EIP-712 typed data signing (tamper-proof)
- EIP-3009 signature verification (ECDSA recovery)
- Database with proper foreign keys and constraints
- Transaction Finality: <1 second (Arc deterministic finality)
- Agent Decision Time: 5-15 seconds (GPT-4o reasoning)
- x402 Verification: <50ms
- Database Queries: <50ms (indexed PostgreSQL)
This is a personal project demonstrating autonomous agent commerce and x402 payment facilitation. Feedback and suggestions welcome!
MIT License - See LICENSE file for details
Built with:
- Circle - USDC infrastructure and Arc blockchain
- OpenAI - GPT-4o for agent reasoning
- x402.org - Payment protocol specification
- Coinbase - x402 reference implementation
- PostgreSQL - Production-grade database
- Nethereum - .NET Ethereum library for EIP-712 signing
Questions? Reach out:
- GitHub Issues: Create an issue
- Twitter: https://x.com/kevlondonbtc
Built in January 2026 using AI-assisted development.
Autonomous commerce + x402 payments on institutional settlement infrastructure.