Service Map
Agentic Wallet consists of 7 services + 2 apps orchestrated through a central API Gateway:| Service | Port | Responsibility |
|---|---|---|
apps/api-gateway | 3000 | Auth, tenant scope checks, rate limiting, response normalization, routing |
services/wallet-engine | 3002 | Wallet creation, key custody, signing APIs, SOL/SPL balance reads |
services/policy-engine | 3003 | Allow/deny/require_approval rule evaluation |
services/agent-runtime | 3004 | Agent lifecycle, capabilities, execution modes, treasury/strategy endpoints |
services/protocol-adapters | 3005 | Protocol registry, quote/build endpoints, escrow adapter |
services/transaction-engine | 3006 | Transaction lifecycle, simulation, policy gate, submit/confirm, proofs, outbox |
services/audit-observability | 3007 | Audit events and metrics aggregation |
services/mcp-server | 3008 | MCP-compatible tools and generic gateway proxy tool |
packages/common | N/A | Shared schemas, types, validation |
packages/sdk | N/A | Typed client for API gateway |
API Gateway (Port 3000)
apps/api-gateway
Entry point for all external requests
Responsibilities
- Authentication: API key validation (
x-api-keyheader) - Authorization: Route-based scope checking (wallets, transactions, policies, agents, protocols, etc.)
- Tenant Isolation: Optional tenant boundary enforcement (
x-tenant-idheader) - 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
| Route Pattern | Target Service | Scope |
|---|---|---|
/api/v1/wallets/** | wallet-engine | wallets |
/api/v1/transactions/** | transaction-engine | transactions |
/api/v1/policies/** | policy-engine | policies |
/api/v1/agents/** | agent-runtime | agents |
/api/v1/protocols/** | protocol-adapters | protocols |
/api/v1/risk/** | transaction-engine | risk |
/api/v1/audit/** | audit-observability | audit |
/mcp/** | mcp-server | mcp |
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 diskmemory: Ephemeral in-memorykms: Key management servicehsm: Hardware security modulempc: 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
cryptomodule - RPC:
@solana/web3.js,@solana/spl-token
Configuration
Key Endpoints
POST /api/v1/wallets- Create new walletGET /api/v1/wallets/:walletId- Get wallet infoGET /api/v1/wallets/:walletId/balance- Get SOL balanceGET /api/v1/wallets/:walletId/tokens- Get SPL token balancesPOST /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
denyon evaluation errors
Supported Rule Types
Spending & Rate Controls
Spending & Rate Controls
spending_limit: Max lamports per transaction or time windowrate_limit: Max transactions per time periodtime_window: Restrict execution to specific hours/days
Address & Program Controls
Address & Program Controls
address_allowlist: Permitted destination addressesaddress_blocklist: Blocked destination addressesprogram_allowlist: Permitted Solana program IDstoken_allowlist: Permitted SPL token mintsprotocol_allowlist: Permitted protocol names
Risk Controls
Risk Controls
max_slippage: Maximum slippage tolerance for swapsprotocol_risk: Protocol-specific risk parametersportfolio_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 policyPUT /api/v1/policies/:policyId- Update policyGET /api/v1/wallets/:walletId/policies- List wallet policiesPOST /api/v1/evaluate- Evaluate transaction against policiesGET /api/v1/policies/:policyId/versions- Get policy version historyPOST /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.jswith failover pool - Execution Tuning: Adaptive priority fee and compute budget
Configuration
Key Endpoints
Transaction Operations
Transaction Operations
POST /api/v1/transactions- Create transactionGET /api/v1/transactions/:txId- Get transaction statusPOST /api/v1/transactions/:txId/retry- Retry failed transactionPOST /api/v1/transactions/:txId/approve- Approve pending transactionPOST /api/v1/transactions/:txId/reject- Reject pending transactionGET /api/v1/transactions/:txId/proof- Get execution proofGET /api/v1/transactions/:txId/replay- Get replay data
Wallet Queries
Wallet Queries
GET /api/v1/wallets/:walletId/transactions- List wallet transactionsGET /api/v1/wallets/:walletId/pending-approvals- List pending approvalsGET /api/v1/wallets/:walletId/positions- List DeFi positionsGET /api/v1/wallets/:walletId/escrows- List escrow positions
Risk Controls
Risk Controls
GET /api/v1/risk/protocols- List protocol risk configsGET /api/v1/risk/protocols/:protocol- Get protocol risk configPUT /api/v1/risk/protocols/:protocol- Update protocol risk configGET /api/v1/risk/portfolio- List portfolio risk configsGET /api/v1/risk/portfolio/:walletId- Get wallet portfolio riskPUT /api/v1/risk/portfolio/:walletId- Update wallet portfolio risk
Chaos Engineering
Chaos Engineering
GET /api/v1/chaos- Get chaos switchboard configPUT /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
Agent Lifecycle
Agent Lifecycle
POST /api/v1/agents- Create agentGET /api/v1/agents- List agentsGET /api/v1/agents/:agentId- Get agentPUT /api/v1/agents/:agentId/capabilities- Update capabilitiesPOST /api/v1/agents/:agentId/start- Start agentPOST /api/v1/agents/:agentId/stop- Stop agentPOST /api/v1/agents/:agentId/pause- Pause agentPOST /api/v1/agents/:agentId/resume- Resume agent
Budget & Treasury
Budget & Treasury
GET /api/v1/agents/:agentId/budget- Get agent budgetPOST /api/v1/treasury/allocate- Allocate funds to agentPOST /api/v1/treasury/rebalance- Rebalance between agents
Strategy & Backtesting
Strategy & Backtesting
POST /api/v1/strategy/backtest- Run backtestPOST /api/v1/strategy/paper/execute- Paper trade executionGET /api/v1/strategy/paper/:agentId- List paper trades
Capability Manifests
Capability Manifests
POST /api/v1/agents/:agentId/manifest/issue- Issue signed manifestPOST /api/v1/agents/:agentId/manifest/verify- Verify manifest
Execution
Execution
POST /api/v1/agents/:agentId/execute- Execute agent intentGET /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 transfersSPL Token
transfer_spl, create_mint, mint_token - Token operationsJupiter
swap - Aggregated DEX swaps with quote APIMarinade
stake, unstake - Liquid staking (mSOL)Solend
lend_supply, lend_borrow - Lending protocolMetaplex
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_escrowrefund_escrow,dispute_escrow,resolve_disputecreate_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
Registry & Metadata
Registry & Metadata
GET /api/v1/protocols- List all protocolsGET /api/v1/protocols/:protocol/capabilities- Get protocol capabilitiesGET /api/v1/protocols/:protocol/version- Get protocol versionGET /api/v1/protocols/health- Health check all protocolsGET /api/v1/protocols/:protocol/health- Health check specific protocol
Versioning & Migration
Versioning & Migration
POST /api/v1/protocols/:protocol/compatibility-check- Check version compatibilityPOST /api/v1/protocols/:protocol/migrate-intent- Migrate intent between versions
DeFi Operations
DeFi Operations
POST /api/v1/defi/quote- Get swap quotePOST /api/v1/defi/swap- Build swap transactionPOST /api/v1/defi/stake- Build stake transactionPOST /api/v1/defi/unstake- Build unstake transactionPOST /api/v1/defi/lend/supply- Build lend supply transactionPOST /api/v1/defi/lend/borrow- Build lend borrow transaction
Escrow Operations
Escrow Operations
POST /api/v1/escrow/create- Create escrowPOST /api/v1/escrow/:id/accept- Accept escrowPOST /api/v1/escrow/:id/release- Release escrowPOST /api/v1/escrow/:id/refund- Refund escrowPOST /api/v1/escrow/:id/dispute- Dispute escrowPOST /api/v1/escrow/:id/resolve- Resolve dispute
Generic Builder
Generic Builder
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 eventGET /api/v1/audit/events- Query audit eventsPOST /api/v1/metrics/inc- Increment metric counterGET /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.requesttool 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 toolsPOST /mcp/call- Call MCP tool
Available MCP Tools
wallet.create- Create new walletwallet.balance- Get wallet balancetx.create- Create transactiontx.get- Get transactionpolicy.evaluate- Evaluate policyprotocol.quote- Get protocol quoteagent.execute- Execute agent intentrisk.get_protocol- Get protocol risk configrisk.set_protocol- Set protocol risk configgateway.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