Overview
Arcana is a full-stack crypto AI orchestration system that combines paid agent services with blockchain micropayments. Users pay to ask questions, and the system automatically routes those queries through specialized AI agents that charge per-call using the x402 payment protocol.High-Level Architecture
The system consists of three main layers:Frontend
React + Vite application for user interaction, wallet connection, and payment submission
Backend
Express orchestrator that verifies payments, routes queries, and manages agent calls
Agents
Specialized services that provide crypto intelligence through paid x402 endpoints
Architecture Diagram
Component Responsibilities
Frontend (arc-agent-hub)
Wallet Management
Wallet Management
- Connect user wallets via Web3 providers
- Switch to Base Sepolia network
- Display USDC balance and transaction history
Payment Handling
Payment Handling
- Submit USDC payment transactions ($0.03 per query)
- Track transaction confirmation status
- Display payment receipts and proof
Chat Interface
Chat Interface
- Render conversational UI for queries
- Display agent responses with rich formatting
- Show which agents were called for each query
Dashboard
Dashboard
- View available agents and their prices
- Monitor agent performance and reliability
- Manage policy controls (freeze/reactivate agents)
Backend Orchestrator
The backend is the heart of the system, coordinating payments, AI reasoning, and agent calls.- Payment Verification
- AI Orchestration
- x402 Agent Calls
- Policy Enforcement
On-Chain Payment VerificationWhen a query arrives with a transaction hash:
- Fetch transaction receipt from Base Sepolia RPC
- Verify transaction is confirmed and successful
- Validate payment amount ($0.03 USDC minimum)
- Check recipient address matches backend wallet
- Ensure transaction hasn’t been used before
Smart Contracts
Deployed on Base Sepolia:PolicyVault
Stores agent policies, spend limits, and allowlists for governance
Escrow
Manages escrow deposits for trustless agent-to-agent payments
AgentRegistry
Registry of all deployed agents with metadata and addresses
Data Flow
User Query Flow
x402 Payment Flow
See x402 Protocol for detailed protocol specification.Technology Stack
Frontend
- Framework: React 18 + Vite
- Web3: Wagmi + Viem
- UI: TailwindCSS + Radix UI
- State: React Query
Backend
- Runtime: Node.js 18+ + TypeScript
- Framework: Express.js
- AI: Gemini 2.5 Flash API
- x402: @x402/express middleware
Blockchain
- Network: Base Sepolia (Chain ID: 84532)
- Token: USDC (0x036CbD53…)
- RPC: https://sepolia.base.org
- Wallet: Coinbase CDP SDK
Infrastructure
- Database: Supabase (PostgreSQL)
- Contracts: Foundry (Solidity)
- APIs: CoinGecko, DeFiLlama, OpenSea, etc.
Security Considerations
Payment Security
Payment Security
- All payments verified on-chain before query processing
- Transaction hashes tracked to prevent replay attacks
- Payment amounts validated against minimum thresholds
- Failed verifications logged for audit
Agent Security
Agent Security
- Policy-based access control for all agent endpoints
- Circuit breaker protection against failing agents
- Spend limits enforced per-call and per-day
- Allowlists for endpoints and recipient addresses
Key Management
Key Management
- CDP SDK for secure wallet provisioning
- Private keys stored in environment variables
- Separate buyer/seller wallets for each agent
- Admin API key required for policy changes
Scalability & Performance
Caching Strategy: Agent responses cached for 30-60 seconds to reduce API costs and improve latency.
- Parallel Agent Calls: Multiple agents called concurrently when independent
- Preflight Caching: x402 payment requirements cached to avoid duplicate preflights
- Provider Scoring: Pinion runtime tracks agent performance for intelligent routing
- Rate Limiting: Per-endpoint rate limits prevent abuse
Next Steps
x402 Protocol
Learn how HTTP 402 enables pay-per-call agent services
Payment Flow
Understand the end-to-end payment process
Agent Marketplace
Explore the 7 specialized agents and their capabilities