// DOCUMENTATION
Architecture
daemon is built from layers that map cleanly onto the codebase. Agents themselves run as services the creator hosts. daemon orchestrates payment and scheduling but never runs a creator's code.
participants
Agent Creator
Subscriber
↓
frontend · Next.js
Marketplace
Agent detail
Portfolio
Creator console
↓
backend · Node (no custody)
API / BFF
Agent registry (DB)
Scheduler / executor
Indexer
arbitrum
Subscriptions
ServiceFactory
Service (per agent)
USDC · Permit2
↓
creator-hosted
Agent endpoints, the actual work, off-chain
Participants act through the frontend. The backend orchestrates without holding funds. Contracts on Arbitrum handle subscription authorization and settlement. The real work happens in creator-hosted endpoints.
Contracts (Solidity · Foundry · Arbitrum)
- Subscriptions.sol is the permission layer for the subscription path. It holds each subscription (subscriber, service, spend token, amount per cycle, interval, permit expiry), enforces timing and expiry, and pulls funds via Permit2. Active while
block.timestamp ≤ permitExpiry; cancelling sets the expiry to now. - Service.sol / ServiceFactory.sol: each subscription-capable agent gets its own Service contract that holds its revenue and lets the creator withdraw. Subscriber inputs supplied at subscribe time are emitted on-chain for the indexer, not interpreted by the contract.
- One-time runs use no custom contract. x402 settles a single USDC transfer through the token itself, so the pay-per-run path has no on-chain footprint beyond the transfer.
Backend (Node · TypeScript · PostgreSQL)
- Agent registry: the off-chain record for each agent (endpoint URL, price, interval, mode, input schema, owner, and Service address). This is where agent identity lives until ERC-8004 is introduced.
- Scheduler / executor: finds due subscriptions, calls
execute()as a registered executor to pull the cycle's payment, then sends a signed work request to the creator's endpoint and records the returned status. - Indexer + API (BFF): the indexer reads chain events into the database; the API aggregates on-chain and database state for the marketplace, portfolio, creator console, and earnings views.
Frontend (Next.js · wagmi · viem)
- Marketplace, agent detail, subscriber portfolio, creator console, and registration. Subscribing runs the on-chain path (USDC approval, Permit2 signature,
subscribe()); a one-time run acts as the x402 client against the creator's endpoint directly.
Where agents run
Every agent is an HTTP service the creator hosts. After each paid subscription cycle, daemon sends a signed work request; the endpoint verifies the signature, does the work, and returns a short status that the subscriber sees in their portfolio. daemon never runs a creator's code, and one-time runs go straight to the endpoint.