Skip to main content

Service Map

Agentic Wallet consists of 7 services + 2 apps orchestrated through a central API Gateway:

API Gateway (Port 3000)

apps/api-gateway

Entry point for all external requests

Responsibilities

  • Authentication: API key validation (x-api-key header)
  • Authorization: Route-based scope checking (wallets, transactions, policies, agents, protocols, etc.)
  • Tenant Isolation: Optional tenant boundary enforcement (x-tenant-id header)
  • Rate Limiting: Per-key rate limiting (default 120 req/min)
  • Response Normalization: Converts all upstream responses to stable machine envelope
  • Routing: Proxies requests to appropriate backend services

Technology Stack

  • Framework: Hono
  • Runtime: Node.js
  • State: In-memory rate limit tracking

Configuration

Normalized Response Envelope

Every response includes:

Routing Table


Wallet Engine (Port 3002)

services/wallet-engine

Key custody and signing boundary

Responsibilities

  • Wallet Creation: Generate new Solana keypairs
  • Key Storage: Persist encrypted private keys
  • Transaction Signing: Sign legacy and versioned transactions
  • Message Signing: Sign arbitrary messages (not yet exposed)
  • Balance Queries: Fetch SOL balance and SPL token balances
  • Signer Backend Abstraction: Support multiple custody strategies

Key Features

Pluggable Backends

  • encrypted-file: AES-256-GCM on disk
  • memory: Ephemeral in-memory
  • kms: Key management service
  • hsm: Hardware security module
  • mpc: Multi-party computation

Encryption Details

  • Algorithm: AES-256-GCM
  • Key Derivation: scrypt
  • Per-record: Random salt + IV
  • Auth Tag: Verified on decrypt

Technology Stack

  • Framework: Hono
  • Storage: SQLite (metadata) + file storage (encrypted keys)
  • Crypto: Node.js crypto module
  • RPC: @solana/web3.js, @solana/spl-token

Configuration

Key Endpoints

  • POST /api/v1/wallets - Create new wallet
  • GET /api/v1/wallets/:walletId - Get wallet info
  • GET /api/v1/wallets/:walletId/balance - Get SOL balance
  • GET /api/v1/wallets/:walletId/tokens - Get SPL token balances
  • POST /api/v1/wallets/:walletId/sign - Sign transaction
The wallet-engine is the only service that can read private keys and sign transactions. This creates a security boundary where agents and external clients never have access to key material.

Policy Engine (Port 3003)

services/policy-engine

Policy evaluation and rule engine

Responsibilities

  • Policy Creation: Define wallet-specific policies with versioned rules
  • Policy Evaluation: Execute rule evaluation for transaction requests
  • Rule Types: Support 11 rule types (spending limits, allowlists, rate limits, etc.)
  • Versioning: Track policy version history with migration support
  • Fail-Secure: Return deny on evaluation errors

Supported Rule Types

  • spending_limit: Max lamports per transaction or time window
  • rate_limit: Max transactions per time period
  • time_window: Restrict execution to specific hours/days
  • address_allowlist: Permitted destination addresses
  • address_blocklist: Blocked destination addresses
  • program_allowlist: Permitted Solana program IDs
  • token_allowlist: Permitted SPL token mints
  • protocol_allowlist: Permitted protocol names
  • max_slippage: Maximum slippage tolerance for swaps
  • protocol_risk: Protocol-specific risk parameters
  • portfolio_risk: Portfolio-level exposure limits

Technology Stack

  • Framework: Hono
  • Storage: SQLite (policies + evaluation state)
  • Validation: Zod schemas from @agentic-wallet/common

Configuration

Key Endpoints

  • POST /api/v1/policies - Create policy
  • PUT /api/v1/policies/:policyId - Update policy
  • GET /api/v1/wallets/:walletId/policies - List wallet policies
  • POST /api/v1/evaluate - Evaluate transaction against policies
  • GET /api/v1/policies/:policyId/versions - Get policy version history
  • POST /api/v1/policies/:policyId/migrate - Migrate policy to new version

Decision Output


Transaction Engine (Port 3006)

services/transaction-engine

Transaction orchestration and execution pipeline

Responsibilities

  • Transaction Lifecycle Management: Orchestrate full execution pipeline
  • Build: Construct unsigned transactions (local or via protocol-adapters)
  • Simulation: Pre-execution validation via Solana RPC
  • Risk Evaluation: Protocol risk and portfolio risk checks
  • Policy Gate: Call policy-engine for evaluation
  • Approval Gate: Pause for manual approval when required
  • Signing: Request signature from wallet-engine
  • Submission: Submit to Solana RPC (or Kora for gasless)
  • Confirmation: Wait for transaction confirmation
  • Proof Generation: Create execution proof with hashes
  • Position Tracking: Index DeFi positions (stake, lend, escrow)
  • Durable Outbox: Queue with lease/retry for reliability

Transaction Lifecycle States

Technology Stack

  • Framework: Hono
  • Storage: SQLite (transactions, outbox, risk configs, positions, escrows, proofs)
  • RPC: @solana/web3.js with failover pool
  • Execution Tuning: Adaptive priority fee and compute budget

Configuration

Key Endpoints

  • POST /api/v1/transactions - Create transaction
  • GET /api/v1/transactions/:txId - Get transaction status
  • POST /api/v1/transactions/:txId/retry - Retry failed transaction
  • POST /api/v1/transactions/:txId/approve - Approve pending transaction
  • POST /api/v1/transactions/:txId/reject - Reject pending transaction
  • GET /api/v1/transactions/:txId/proof - Get execution proof
  • GET /api/v1/transactions/:txId/replay - Get replay data
  • GET /api/v1/wallets/:walletId/transactions - List wallet transactions
  • GET /api/v1/wallets/:walletId/pending-approvals - List pending approvals
  • GET /api/v1/wallets/:walletId/positions - List DeFi positions
  • GET /api/v1/wallets/:walletId/escrows - List escrow positions
  • GET /api/v1/risk/protocols - List protocol risk configs
  • GET /api/v1/risk/protocols/:protocol - Get protocol risk config
  • PUT /api/v1/risk/protocols/:protocol - Update protocol risk config
  • GET /api/v1/risk/portfolio - List portfolio risk configs
  • GET /api/v1/risk/portfolio/:walletId - Get wallet portfolio risk
  • PUT /api/v1/risk/portfolio/:walletId - Update wallet portfolio risk
  • GET /api/v1/chaos - Get chaos switchboard config
  • PUT /api/v1/chaos - Update chaos switchboard config

Execution Proof Structure


Agent Runtime (Port 3004)

services/agent-runtime

Agent lifecycle and autonomous execution

Responsibilities

  • Agent Management: Create, start, stop, pause, resume agents
  • Capability Control: Intent and protocol allowlists per agent
  • Execution Modes: Supervised vs autonomous operation
  • Autonomous Decision Engine: Rule-based autonomous strategy execution
  • Budget Management: Per-agent spending budgets
  • Capability Manifests: Issue and verify signed capability manifests
  • Strategy Execution: Backtesting and paper trading
  • Treasury Operations: Budget allocation and rebalancing

Execution Modes

Supervised

Agent executes only when explicitly called via API. Used for agent-driven execution where the agent makes all decisions.

Autonomous

Agent runs on a scheduler with built-in decision engine. Executes strategies based on conditions, cadence, and cooldowns.

Technology Stack

  • Framework: Hono
  • Storage: SQLite (agents, budgets, strategies, paper trades)
  • Scheduler: Interval-based loop with per-agent decision state
  • Manifest Signing: HMAC-SHA256 with secret

Configuration

Key Endpoints

  • POST /api/v1/agents - Create agent
  • GET /api/v1/agents - List agents
  • GET /api/v1/agents/:agentId - Get agent
  • PUT /api/v1/agents/:agentId/capabilities - Update capabilities
  • POST /api/v1/agents/:agentId/start - Start agent
  • POST /api/v1/agents/:agentId/stop - Stop agent
  • POST /api/v1/agents/:agentId/pause - Pause agent
  • POST /api/v1/agents/:agentId/resume - Resume agent
  • GET /api/v1/agents/:agentId/budget - Get agent budget
  • POST /api/v1/treasury/allocate - Allocate funds to agent
  • POST /api/v1/treasury/rebalance - Rebalance between agents
  • POST /api/v1/strategy/backtest - Run backtest
  • POST /api/v1/strategy/paper/execute - Paper trade execution
  • GET /api/v1/strategy/paper/:agentId - List paper trades
  • POST /api/v1/agents/:agentId/manifest/issue - Issue signed manifest
  • POST /api/v1/agents/:agentId/manifest/verify - Verify manifest
  • POST /api/v1/agents/:agentId/execute - Execute agent intent
  • GET /api/v1/agents/:agentId/autonomy/state - Get autonomy state

Protocol Adapters (Port 3005)

services/protocol-adapters

Protocol-specific transaction building

Responsibilities

  • Adapter Registry: Register and manage protocol adapters
  • Quote Fetching: Get swap quotes from DEX protocols
  • Transaction Building: Construct protocol-specific instructions
  • Health Checks: Verify protocol adapter health and dependencies
  • Version Management: Track adapter versions and migrations
  • Intent Migration: Migrate intents between adapter versions

Supported Protocols (7 + system)

System Program

transfer_sol - Native SOL transfers

SPL Token

transfer_spl, create_mint, mint_token - Token operations

Jupiter

swap - Aggregated DEX swaps with quote API

Marinade

stake, unstake - Liquid staking (mSOL)

Solend

lend_supply, lend_borrow - Lending protocol

Metaplex

NFT minting intents (static builder)

Orca

DEX swap intents (static builder)

Raydium

DEX swap intents (static builder)

Escrow (Anchor)

9 escrow instructions backed by real on-chain program:
  • create_escrow, accept_escrow, release_escrow
  • refund_escrow, dispute_escrow, resolve_dispute
  • create_milestone_escrow, release_milestone, x402_pay

Technology Stack

  • Framework: Hono
  • Storage: In-memory adapter registry
  • External APIs: Jupiter API for quotes, protocol-specific APIs

Configuration

Key Endpoints

  • GET /api/v1/protocols - List all protocols
  • GET /api/v1/protocols/:protocol/capabilities - Get protocol capabilities
  • GET /api/v1/protocols/:protocol/version - Get protocol version
  • GET /api/v1/protocols/health - Health check all protocols
  • GET /api/v1/protocols/:protocol/health - Health check specific protocol
  • POST /api/v1/protocols/:protocol/compatibility-check - Check version compatibility
  • POST /api/v1/protocols/:protocol/migrate-intent - Migrate intent between versions
  • POST /api/v1/defi/quote - Get swap quote
  • POST /api/v1/defi/swap - Build swap transaction
  • POST /api/v1/defi/stake - Build stake transaction
  • POST /api/v1/defi/unstake - Build unstake transaction
  • POST /api/v1/defi/lend/supply - Build lend supply transaction
  • POST /api/v1/defi/lend/borrow - Build lend borrow transaction
  • POST /api/v1/escrow/create - Create escrow
  • POST /api/v1/escrow/:id/accept - Accept escrow
  • POST /api/v1/escrow/:id/release - Release escrow
  • POST /api/v1/escrow/:id/refund - Refund escrow
  • POST /api/v1/escrow/:id/dispute - Dispute escrow
  • POST /api/v1/escrow/:id/resolve - Resolve dispute
  • POST /api/v1/build - Generic intent builder (used by transaction-engine)

Audit & Observability (Port 3007)

services/audit-observability

Audit event stream and metrics aggregation

Responsibilities

  • Audit Event Ingestion: Accept audit events from all services
  • Event Storage: Persist events to SQLite
  • Event Querying: Query audit log by entity, type, or time range
  • Metrics Counting: Increment counters for operational metrics
  • Metrics Retrieval: Retrieve counter values

Technology Stack

  • Framework: Hono
  • Storage: SQLite (audit events + metrics)

Configuration

Key Endpoints

  • POST /api/v1/audit/events - Submit audit event
  • GET /api/v1/audit/events - Query audit events
  • POST /api/v1/metrics/inc - Increment metric counter
  • GET /api/v1/metrics - Get all metric counters

Audit Event Schema


MCP Server (Port 3008)

services/mcp-server

Model Context Protocol tool interface

Responsibilities

  • MCP Tools: Expose wallet operations as MCP tools
  • Gateway Proxy: Generic gateway.request tool for arbitrary API calls
  • Tool Discovery: List available tools with schemas

Technology Stack

  • Framework: Hono
  • Protocol: MCP (Model Context Protocol)

Configuration

Key Endpoints

  • GET /mcp/tools - List available MCP tools
  • POST /mcp/call - Call MCP tool

Available MCP Tools

  • wallet.create - Create new wallet
  • wallet.balance - Get wallet balance
  • tx.create - Create transaction
  • tx.get - Get transaction
  • policy.evaluate - Evaluate policy
  • protocol.quote - Get protocol quote
  • agent.execute - Execute agent intent
  • risk.get_protocol - Get protocol risk config
  • risk.set_protocol - Set protocol risk config
  • gateway.request - Generic gateway proxy (validated routes only)

Shared Packages

packages/common

@agentic-wallet/common

Shared schemas, types, and validation
  • Zod Schemas: All request/response schemas
  • Type Exports: TypeScript types for all entities
  • Validation: Centralized validation logic

packages/sdk

@agentic-wallet/sdk

Typed TypeScript client
  • Type-Safe Client: Fully typed API client
  • Error Handling: Normalized error responses
  • Request Building: Helper methods for all endpoints

Inter-Service Communication

Communication Pattern

All services communicate via HTTP REST APIs on localhost:

Service Discovery

Services are discovered via environment variables:

Error Handling

Services use fail-secure error handling:
  • If policy-engine is unreachable → transaction-engine returns deny
  • If wallet-engine signing fails → transaction-engine marks transaction as failed
  • If RPC is unavailable → RPC pool failover kicks in

Best-Effort Sinks

Audit and metrics calls are best-effort:

Next Steps

Execution Flow

Deep dive into transaction and escrow lifecycles

Trust Boundaries

Security model and control boundaries