Cortex

Architecture

Cortex is a Base-native protocol for agentic commerce: onchain identity, policy, intents, merchant discovery, payment terms, receipts, disputes, analytics, and machine-readable APIs.

System Shape

Agent / Smart Account
  -> AgentRegistry + PolicyModule + PolicyAccount
  -> IntentBook <-> SolverRegistry / Solver service

Merchant / Service Operator
  -> CommerceRegistry
     merchants, services, facilitators, quotes, receipts, fulfillment, trust signals, disputes

Attestors
  -> AttestorRegistry + AttestationRegistry

All contract events
  -> Indexer -> Postgres -> REST API / MCP / Dashboard

Core Flows

  1. Agent identity and policy — register an agent, configure spend limits, target/function allowlists, session keys, and signed payment budgets.
  2. Intent execution — sign an EIP-712 intent, inspect/select solver bids, and enforce selected solver, amounts, execution commitment, deadline, and optional attestations.
  3. Merchant discovery — register merchant, service, facilitator, metadata URI/hash, and service capability hash onchain.
  4. Quote commitment — bind merchant, service, agent, token, amount, payment rail, expiry, nonce, resource hash, terms hash, optional x402 payload hash, and fee terms.
  5. Receipt, fulfillment, and dispute — record settlement, result/resource hashes, fulfillment hashes, trust signals, and dispute resolution signals for analytics and reputation.
  6. Index and query — index events into Postgres and expose them through REST, MCP, and dashboard views.

Payment Rails

Wallet transfers

Native or ERC-20 payments governed by spend limits and allowlists.

Swaps

DEX/router calls governed by intent constraints, target policies, and token spend limits.

Facilitators

Delegated payment flows where a facilitator settles on behalf of an authorization.

x402

Web-native payment acceptance bound through x402PayloadHash when used.

Contract Architecture

ContractPurposeKey Feature
AgentRegistryAgent identityOwner, metadata URI, pubkey, capabilities hash
PolicyModulePolicy enforcementSpend limits, allowlists, signed payment policy, replay protection
PolicyAccountSmart accountPolicy-gated execution, session keys, guardian freeze
IntentBookIntent lifecycleEIP-712 intents, selected bids, solver fill enforcement
SolverRegistrySolver discoveryOperator metadata, bond, fill quality counters
AttestorRegistryAttestor discoveryOperator metadata and schema support
AttestationRegistryProvenanceSchema-based attestations and revocation
CommerceRegistryAgentic commerceMerchants, services, facilitators, quotes, receipts, fulfillment, trust signals, disputes

Indexed Data

TablePurpose
agentsAgent identity and owner lookups
intentsIntent state, constraints, and status
solver_bidsBid market inspection
fillsSolver fills, result hashes, trace hashes
policiesAccount spend, allowlist, and signed payment policy state
solversSolver metadata and performance metrics
attestorsAttestor metadata and counters
merchantsMerchant discovery and payout context
servicesService discovery and capability lookup
facilitatorsPayment facilitator discovery
quotesCanonical quote/payment terms and fee instrumentation
commerce_receiptsSettled commerce records and fulfillment hashes
disputesRefund/dispute/reputation signals
trust_signalsVerification, risk, compliance, and fulfillment signals
tx_receiptsHuman and machine transaction explanations

API, MCP, and Dashboard

  • REST API exposes indexed state for agents and frontends.
  • MCP tools expose selected API functionality to model-driven agents.
  • Dashboard reads commerce analytics, merchant/service discovery, receipts, and disputes.
  • Analytics include volume, settled volume, payment rail mix, zero-fee protocol fields, dispute counts, trust signal counts, and facilitator/merchant/service leaderboards.

Technology Stack

Contracts:      Solidity 0.8.24, Foundry, OpenZeppelin
Solver:         TypeScript, viem, node-postgres
Indexer:        TypeScript, viem, node-postgres
API:            TypeScript, Express 4, node-postgres
Dashboard/docs: Next.js, React, Tailwind
Database:       PostgreSQL 16
Local dev:      Anvil, Docker Compose