AEP Cookbook

Single reference for AEP deployment, policies, integration, and operations. For detailed guidance, see the skills in skills/.

IMPORTANT

Never commit PRIVATE_KEY or expose it in logs. Use environment variables or a secure key manager. Prefer PRIVATE_KEY env over --private-key flag (avoids process listing). Use hardware wallet for production.


Quick Start

npm-first (recommended): see Getting started — Quick start — npx @economicagents/cli@0.2.0 deploy against the published factory; no Foundry clone.

From source (custom factory):

  1. Deploy factory: cd contracts && forge script script/Deploy.s.sol --rpc-url base_sepolia --broadcast (requires .env with PRIVATE_KEY, BASE_SEPOLIA_RPC) → note factory address
  2. Deploy account: npx @economicagents/cli@0.2.0 deploy --factory 0xFactoryAddress (owner derived from PRIVATE_KEY) or --owner 0x...
  3. Set policies: npx @economicagents/cli@0.2.0 policy-set -m <module> --max-per-tx 1000000 --max-daily 5000000 --max-weekly 20000000 (get module via aep modules)
  4. Optional — relationships: cd contracts && forge script script/DeployRelationships.s.sol --rpc-url base_sepolia --broadcast → add factory addresses to ~/.aep/config.json
  5. Optional — intent resolution (self-host): cd packages/indexer && pnpm run build && npx aep-index sync (index at ~/.aep/index/); cd packages/api && pnpm run build && node dist/index.js (POST /resolve on port 3847). Hosted reference at https://api.economicagents.org is offline (HTTP 521) as of August 2026.

Full config (~/.aep/config.json): factoryAddress, rpcUrl, account (from deploy); for counterparty: identityRegistryAddress, reputationRegistryAddress; for execute: bundlerRpcUrl; for resolve: indexPath; optional indexDatabaseUrl — PostgreSQL URL for hybrid provider search (overridden by env AEP_INDEX_DATABASE_URL when set); for relationships: creditFacilityFactoryAddress, escrowFactoryAddress, revenueSplitterFactoryAddress, slaFactoryAddress; for monitor: monitor.accounts, monitor.facilities, monitor.slas, monitor.webhookUrl, monitor.pollIntervalMs; for fleet: fleets.

Provider index (Postgres optional): With AEP_INDEX_DATABASE_URL or indexDatabaseUrl, run aep-index migrate once, then sync and embed. Vector hybrid search uses OpenAI (OPENAI_API_KEY, optional AEP_EMBEDDING_MODEL). Without a DB URL, the index stays in ~/.aep/index/ (providers.json + optional SQLite search.db). Optional namespace: AEP_INDEX_DATASET_ID.


Quick Reference

TaskCommand
Deploy factorycd contracts && forge script script/Deploy.s.sol --rpc-url base_sepolia --broadcast
Deploy accountaep deploy --factory 0x... (or --owner 0x...)
Set budget capsaep policy-set -m <module> --max-per-tx 1000000 --max-daily 5000000 --max-weekly 20000000
Block addressaep counterparty add-block 0x... -m <module>
Allow list modeaep counterparty set-use-allow-list true -m <module>
Check policy (x402)aep check-policy -a 500000 -t 0xRecipient
Emergency freezeaep freeze
On-chain monitoraep monitor
Provider probeaep provider probe <url> or aep provider probe --agent-id <id>
Execute UserOpaep execute -t 0xRecipient -v 1000000 -d 0x --bundler https://...

Policy Modules

BudgetPolicy

CapDescription0 =
maxPerTxMax per transactionUnlimited
maxDailyMax per daily windowUnlimited
maxWeeklyMax per weekly windowUnlimited
maxPerTaskMax per task windowDisabled
taskWindowSecondsTask window lengthDisabled

Skills: aep-budget, aep-rate-limit

CounterpartyPolicy

  • Default: All allowed except block list
  • Address allow list: Only allowlisted addresses
  • Agent allow list: Only wallets of allowed ERC-8004 agent IDs
  • Global min-reputation: Only verified agents with reputation >= min

Skill: aep-counterparty

RateLimitPolicy

aep rate-limit set -m <module> --max-tx <n> --window-seconds <s> — set max transactions per window (owner only). Example: aep rate-limit set -m 0x... --max-tx 10 --window-seconds 3600 (10 tx/hour).

Skill: aep-rate-limit


Deployment

Full testnet deployment: See Deployment guide for deploy-base-sepolia.sh, deployed addresses, mainnet preflight, and post-deploy services.

Base Sepolia Addresses

ContractAddress
EntryPoint v0.70x0000000071727De22E5E9d8BAf0edAc6f37da032
Identity Registry (ERC-8004)0x8004A818BFB912233c491871b3d84c89A494BD9e
Reputation Registry (ERC-8004)0x8004B663056A597Dffe9eCcC1965A193B7388713
Validation Registry (ERC-8004)0x8004Cb1BF31DAf7788923b405b754f57acEB4272
USDC0x036CbD53842c5426634e7929541eC2318f3dCF7e
AEPAccountFactoryDeploy via Deploy.s.sol
CreditFacilityFactoryDeploy via DeployRelationships.s.sol
ConditionalEscrowFactoryDeploy via DeployRelationships.s.sol
RevenueSplitterFactoryDeploy via DeployRelationships.s.sol
SLAContractFactoryDeploy via DeployRelationships.s.sol

Skill: aep-deploy


Integration

MCP Config

{
  "mcpServers": {
    "aep": {
      "command": "npx",
      "args": ["-y", "@economicagents/mcp@0.2.0"]
    }
  }
}

See MCP reference for global install and monorepo paths.

Tools: get_balance, get_policy_state, set_budget_caps, resolve_intent, get_analytics, get_credit_score, get_recommendations, fleet_summary, fleet_accounts, fleet_alerts, credit_state, escrow_state, splitter_state, sla_state.

OpenClaw Skills

cp -r skills/aep-budget skills/aep-counterparty skills/aep-x402 skills/aep-mpp skills/aep-rate-limit skills/aep-relationships ~/.openclaw/skills/

Or symlink: ln -s /path/to/AEP/skills/aep-budget ~/.openclaw/skills/aep-budget (and similarly for aep-counterparty, aep-x402, aep-mpp, aep-rate-limit, aep-relationships)

Skill: aep-integration


Economic Relationships

ContractCLI prefix
CreditFacilityaep credit
ConditionalEscrowaep escrow
RevenueSplitteraep splitter
SLAContractaep sla

MCP tools: credit_state, escrow_state, splitter_state, sla_state.

WARNING

Validator selection: Escrow and SLA contracts rely on validator honesty. Use reputable validators; consider multi-sig for high-value flows. See THREAT-MODEL § Validator Selection.

Skill: aep-relationships


Monetization

  • Treasury: treasuryAddress in ~/.aep/config.json or AEP_TREASURY_ADDRESS env
  • API paywall: Set AEP_TREASURY_ADDRESS (or treasuryAddress in config) and AEP_RESOLVE_PRICE to gate POST /resolve via x402
  • Relationship fees: --origination-fee (credit), --setup-fee (escrow, SLA). Use 0 for no fee.
  • Fee-free mode: Deploy relationship factories with AEP_TREASURY_ADDRESS unset

Resolution paths and paywall

PathPaywallUse case
REST POST /resolveYes, when treasury setAny API instance with treasury configured
MCP (resolve_intent)NoResolver inside the MCP server process
CLI (aep resolve)NoLocal resolver; --api-url targets a remote API (paywalled if that server enables it)

Skill: aep-monetization


Fleet Management

Manage multiple AEP accounts as a fleet. Config in ~/.aep/config.json:

{
  "fleets": {
    "fleet-1": {
      "accounts": ["0x...", "0x..."],
      "name": "Production Agents"
    }
  }
}
CommandDescription
aep fleet listList configured fleets
aep fleet summary <id>Aggregate analytics for fleet
aep fleet freeze <id>Freeze all accounts (PRIVATE_KEY = owner)

API: GET /fleet/:id/summary, /fleet/:id/accounts, /fleet/:id/alerts. When AEP_FLEET_API_KEY is set, these require Authorization: Bearer <key> or X-Fleet-API-Key.


On-Chain Event Monitor

Run aep monitor to watch for security-relevant events (Frozen, DefaultDeclared, BreachDeclared, PolicyRecordSpendFailed, UserOperationRevertReason). Alerts emitted as JSON lines to stdout; optional webhook POST.

Config (~/.aep/config.json):

{
  "monitor": {
    "accounts": ["0x..."],
    "facilities": ["0x..."],
    "slas": ["0x..."],
    "webhookUrl": "https://...",
    "pollIntervalMs": 12000
  }
}

If monitor is omitted, uses account for accounts. See INCIDENT-RESPONSE-PLAYBOOK.


Key Management

CAUTION

Owner (cold): Master key — upgrades, policy changes, emergency freeze. Store in hardware wallet. Compromise allows full account control.

  • Kill switch: aep freeze blocks all execution on suspected compromise.
  • Operator/session keys: Deferred; owner-only implemented.

Skill: aep-key-management