Skip to main content

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)

  • Connect user wallets via Web3 providers
  • Switch to Base Sepolia network
  • Display USDC balance and transaction history
  • Submit USDC payment transactions ($0.03 per query)
  • Track transaction confirmation status
  • Display payment receipts and proof
  • Render conversational UI for queries
  • Display agent responses with rich formatting
  • Show which agents were called for each query
  • 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.
On-Chain Payment VerificationWhen a query arrives with a transaction hash:
  1. Fetch transaction receipt from Base Sepolia RPC
  2. Verify transaction is confirmed and successful
  3. Validate payment amount ($0.03 USDC minimum)
  4. Check recipient address matches backend wallet
  5. Ensure transaction hasn’t been used before
Only after successful verification does the backend process the query.

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

1

User Submits Query

User types a question and signs a USDC transfer transaction for $0.03
2

Payment Verification

Backend verifies the transaction on Base Sepolia and confirms receipt
3

Intent Analysis

Gemini analyzes the query to determine which agents to call
4

Agent Execution

Backend calls selected agents via x402, paying per call (e.g., Oracle 0.01,Yield0.01, Yield 0.01)
5

Response Synthesis

Gemini combines agent responses into a coherent answer
6

User Receives Answer

Frontend displays the answer with payment proof and agent attribution

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

Demo Environment: This system runs on Base Sepolia testnet with test USDC. Not for production use.
  • 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
  • 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
  • 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

Build docs developers (and LLMs) love