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):
- 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 - Deploy account:
npx @economicagents/cli@0.2.0 deploy --factory 0xFactoryAddress(owner derived from PRIVATE_KEY) or--owner 0x... - Set policies:
npx @economicagents/cli@0.2.0 policy-set -m <module> --max-per-tx 1000000 --max-daily 5000000 --max-weekly 20000000(get module viaaep modules) - Optional — relationships:
cd contracts && forge script script/DeployRelationships.s.sol --rpc-url base_sepolia --broadcast→ add factory addresses to~/.aep/config.json - 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 athttps://api.economicagents.orgis 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
| Task | Command |
|---|---|
| Deploy factory | cd contracts && forge script script/Deploy.s.sol --rpc-url base_sepolia --broadcast |
| Deploy account | aep deploy --factory 0x... (or --owner 0x...) |
| Set budget caps | aep policy-set -m <module> --max-per-tx 1000000 --max-daily 5000000 --max-weekly 20000000 |
| Block address | aep counterparty add-block 0x... -m <module> |
| Allow list mode | aep counterparty set-use-allow-list true -m <module> |
| Check policy (x402) | aep check-policy -a 500000 -t 0xRecipient |
| Emergency freeze | aep freeze |
| On-chain monitor | aep monitor |
| Provider probe | aep provider probe <url> or aep provider probe --agent-id <id> |
| Execute UserOp | aep execute -t 0xRecipient -v 1000000 -d 0x --bundler https://... |
Policy Modules
BudgetPolicy
| Cap | Description | 0 = |
|---|---|---|
| maxPerTx | Max per transaction | Unlimited |
| maxDaily | Max per daily window | Unlimited |
| maxWeekly | Max per weekly window | Unlimited |
| maxPerTask | Max per task window | Disabled |
| taskWindowSeconds | Task window length | Disabled |
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
| Contract | Address |
|---|---|
| EntryPoint v0.7 | 0x0000000071727De22E5E9d8BAf0edAc6f37da032 |
| Identity Registry (ERC-8004) | 0x8004A818BFB912233c491871b3d84c89A494BD9e |
| Reputation Registry (ERC-8004) | 0x8004B663056A597Dffe9eCcC1965A193B7388713 |
| Validation Registry (ERC-8004) | 0x8004Cb1BF31DAf7788923b405b754f57acEB4272 |
| USDC | 0x036CbD53842c5426634e7929541eC2318f3dCF7e |
| AEPAccountFactory | Deploy via Deploy.s.sol |
| CreditFacilityFactory | Deploy via DeployRelationships.s.sol |
| ConditionalEscrowFactory | Deploy via DeployRelationships.s.sol |
| RevenueSplitterFactory | Deploy via DeployRelationships.s.sol |
| SLAContractFactory | Deploy 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
| Contract | CLI prefix |
|---|---|
| CreditFacility | aep credit |
| ConditionalEscrow | aep escrow |
| RevenueSplitter | aep splitter |
| SLAContract | aep 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:
treasuryAddressin~/.aep/config.jsonorAEP_TREASURY_ADDRESSenv - API paywall: Set
AEP_TREASURY_ADDRESS(ortreasuryAddressin config) andAEP_RESOLVE_PRICEto gatePOST /resolvevia x402 - Relationship fees:
--origination-fee(credit),--setup-fee(escrow, SLA). Use 0 for no fee. - Fee-free mode: Deploy relationship factories with
AEP_TREASURY_ADDRESSunset
Resolution paths and paywall
| Path | Paywall | Use case |
|---|---|---|
REST POST /resolve | Yes, when treasury set | Any API instance with treasury configured |
MCP (resolve_intent) | No | Resolver inside the MCP server process |
CLI (aep resolve) | No | Local 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"
}
}
}
| Command | Description |
|---|---|
aep fleet list | List 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 freezeblocks all execution on suspected compromise. - Operator/session keys: Deferred; owner-only implemented.
Skill: aep-key-management
Links
- Architecture — Contract hierarchy, validateUserOp flow
- Threat Model — Attack surfaces and mitigations
- Deployment — Sepolia, mainnet, validation, local services