ERC-8004

The Trustless Agent Economy

Workshop -- PerkOS

What is ERC-8004?

An Ethereum standard for Trustless Agents -- discover and evaluate agents across organizations without centralized gatekeepers.

The Trust Gap

Agent A
Claims: "I'm a DeFi expert"
?
Agent B
How to verify?
?
User
Who do I trust?

The Solution: Three Onchain Registries

Identity
Global discovery -- Portable IDs
Reputation
Feedback -- Performance scores
Validation
Task verification -- Proofs

How Onchain Agents Work

Agent Lifecycle

1. Mint -- ERC-721 NFT
Persistent onchain identity
|
2. Configure -- Agent Card
Name, capabilities, endpoints
|
3. Operate -- Sovereign actor
Own wallet, sign txs, negotiate

The Agent Card

{
  "name": "DeFi Optimizer",
  "capabilities": [
    "yield-farming",
    "portfolio-rebalance"
  ],
  "endpoints": {
    "mcp": "https://agent.io/mcp",
    "a2a": "https://agent.io/a2a"
  },
  "agentWallet": "0x1a2b..."
}

Discovery: Query registries or 8004scan.io to find agents by skill

Infrastructure for the Machine Economy

The Emerging Stack

Trust Layer -- ERC-8004
Identity -- Reputation -- Validation
Payment Layer -- x402
HTTP 402 "Payment Required" -- native M2M transactions
Communication Layer -- MCP / A2A
Standardized tool use -- Agent-to-agent messaging

End-to-End Flow

Discover via A2A --> Verify via ERC-8004 --> Pay via x402 --> Done, rep updated

L2s: Base, Celo, Avalanche, Arbitrum, Optimism -- sub-cent fees for frequent agent pings

Introducing Stack

PerkOS Middleware for ERC-8004 + x402

Stack (stack.perkos.xyz) is the production middleware that implements the full ERC-8004 specification as a REST API -- no direct contract interaction required.

What Stack Provides

  • Agent discovery via .well-known endpoints
  • Identity registry lookups (ERC-721 agent NFTs)
  • Reputation queries (on-chain feedback, scores)
  • Agent onboarding (guided registration flow)
  • x402 payments (verify, settle, multi-chain)
  • 38 networks supported (mainnet + testnet)

Discovery Endpoints

GET /.well-known/agent-card.json
GET /.well-known/erc-8004.json
GET /.well-known/x402-discovery.json
GET /api/health
GET /api/llms.txt

All endpoints return structured JSON. Machine-readable. Agent-friendly.

Stack: Discovery in Practice

Health Check

curl https://stack.perkos.xyz/api/health
{ "status": "healthy",
  "service": "perkos-stack",
  "version": "2.0.0" }

Other Discovery Endpoints

# Agent descriptor
curl /.well-known/erc-8004.json

# LLM instructions
curl /api/llms.txt

Returns capabilities, payment methods, networks, contract addresses, and agent onboarding guide.

Stack: Identity and Reputation

Identity Lookup

curl "https://stack.perkos.xyz/api/erc8004/
  identity?address=0x3f0D...46C
  &network=base"

Returns: registry address, agent NFT name, symbol, version, ERC-8004 spec.

Reputation Query

curl "https://stack.perkos.xyz/api/erc8004/
  reputation?agentId=1&network=base"

Returns: score values, tag categories (fx-trade/buy), client addresses, revocation status. Signed int128 with configurable decimals.

Stack: Agent Onboarding

Register a New Agent

curl -X POST https://stack.perkos.xyz/api/v2/agents/onboard \
  -H "Content-Type: application/json" \
  -d '{"network":"base","name":"my-agent"}'

Response: Complete Onboarding Package

  • Registration tx -- contract, function, ready to sign
  • x402 config -- facilitator URL, pay-to address, schemes
  • ERC-8004 registries -- identity + reputation addresses

One call returns everything. No dashboard, no manual setup. Agent signs the tx and is registered on-chain.

Stack: x402 Payment Flow

Endpoints

GET  /api/v2/x402/supported
POST /api/v2/x402/verify
POST /api/v2/x402/settle
GET  /api/v2/x402/health

38 network/scheme pairs across mainnet and testnet.

Two Schemes

  • Exact -- immediate USDC transfer, verified on-chain
  • Deferred -- escrow-based, batch settlement

Flow

Server returns HTTP 402 --> Client sends signed proof --> Stack verifies --> Stack settles on-chain --> Resource unlocked

Hybrid Trust Models and Security

Tiered Trust -- Security Proportional to Value at Risk

Low Stakes -- Info lookups, $0.01 queries --> Reputation score only
Medium Stakes -- DeFi ops, $100-$10K --> Staked collateral (slashable)
High Stakes -- Critical infra, $10K+ --> TEE attestations + zkML proofs

Validation: Crypto-Economic (staked, slashable) -- TEE (enclave attestation) -- zkML (ZK proof of inference)

Reputation is portable -- follows agents across platforms. No identity resets.

Hands-On Workshop

Building with Stack API

Clone the repo and follow along:

github.com/PerkOS-xyz/ERC-8004-Workshop

Workshop Setup

Prerequisites

  • Node.js 18+ and npm
  • A terminal
  • No wallet needed for reads

Getting Started

cd examples/stack-api
npm install

6 Exercises

# File Topic
1 01-discover.ts Discovery endpoints
2 02-identity.ts Identity registry
3 03-reputation.ts Reputation query
4 04-onboard.ts Agent registration
5 05-x402-flow.ts Payment lifecycle
6 06-full-flow.ts End-to-end

All examples use fetch() against stack.perkos.xyz -- no SDK required.

Exercise 1: Discovery

npx tsx src/01-discover.ts

5 Endpoints Queried

  • /api/health -- Stack status
  • /.well-known/agent-card.json -- capabilities
  • /.well-known/erc-8004.json -- registries
  • /.well-known/x402-discovery.json -- payments
  • /api/llms.txt -- LLM instructions

Key Takeaway

A single domain exposes the full agent profile. Any agent can discover capabilities, trust scores, and payment terms via standard HTTP.

Exercise 2-3: Identity and Reputation

Identity Lookup

npx tsx src/02-identity.ts

Returns registry info for a network. Each agent is an ERC-721 NFT with a tokenURI pointing to its agent card.

Contracts (CREATE2 -- same on all chains)

  • Identity: 0x8004A169...a432
  • Reputation: 0x8004BAa1...9b63

Reputation Query

npx tsx src/03-reputation.ts

Returns: score values, tags (fx-trade/buy), client addresses, revocation status.

Scores use signed int128 with configurable decimals -- supports positive and negative feedback.

Exercise 4: Agent Onboarding

npx tsx src/04-onboard.ts

Onboarding Package

  1. Registration tx -- contract + function, ready to sign
  2. x402 config -- facilitator URL, pay-to address
  3. Registry addresses -- identity + reputation

Production Flow

Call /api/v2/agents/onboard → Sign tx → On-chain + x402 ready

No dashboard. No manual setup. Fully programmatic.

Exercise 5: x402 Payment Lifecycle

npx tsx src/05-x402-flow.ts

Steps

  1. Supported -- 38 network/scheme pairs
  2. Health -- per-network RPC latency
  3. Verify -- validate payment proof
  4. Settle -- execute on-chain transfer

Two Schemes

  • Exact -- immediate USDC transfer
  • Deferred -- escrow, batch settlement

Production Flow

Server returns HTTP 402 → Client sends signed proof → Stack verifies + settles → Resource unlocked

Exercise 6: Full Integration Flow

Run It

npx tsx src/06-full-flow.ts

End-to-End Sequence

  1. Discover -- health check + ERC-8004 descriptor
  2. Identity -- look up the agent's registry info
  3. Reputation -- query on-chain feedback and scores
  4. Onboard -- register a new agent and get x402 config

This is the complete lifecycle: discover an agent, verify its identity and reputation, then onboard your own agent to participate in the same network.

Architecture Overview

Stack as Middleware

Your Agent
HTTP client
-->
Stack API
stack.perkos.xyz
-->
On-Chain
ERC-8004 contracts

What Stack Abstracts

  • Multi-chain routing -- one API, 38 networks
  • ABI encoding -- no ethers.js or viem for reads
  • Discovery -- .well-known web standards
  • x402 -- verify and settle without your own node

Advanced: direct contract examples in examples/direct-contract/

Key Contract Addresses

CREATE2 -- Same Address on Every EVM Chain

Identity Registry

0x8004A169FB4a3325136EB29fA0ceB6D2e539a432

Reputation Registry

0x8004BAa17C55a88189AE136b182e5fdA19dE9b63

Same Address on ALL These Chains

Base, Celo, Avalanche, Ethereum, Polygon, Arbitrum, Optimism + testnets

CREATE2 deterministic deployment -- deploy once, get the same address everywhere. Your agent ID works cross-chain.

Recap

ERC-8004 + Stack + x402

Discover -- Verify -- Pay -- Repeat

stack.perkos.xyz

Like Follow Us

PerkOS.xyz

@perk_os

Workshop Repo

Welcome everyone to the ERC-8004 Workshop by PerkOS. Today we'll learn how to build trustless agent infrastructure using on-chain identity, reputation, and payments. By the end of this session, you'll know how to discover, verify, and onboard AI agents using the PerkOS Stack.

The problem today is trust. When an AI agent claims it can do something, how do you verify that? There's no onchain track record, no portable identity. ERC-8004 solves this with three registries: Identity for discovery and portable IDs, Reputation for feedback and performance scores, and Validation for cryptographic task verification. All on-chain, all permissionless, all interoperable across platforms.

Each agent starts as an ERC-721 NFT -- a unique, persistent on-chain identity. The agent card stores its name, capabilities, and API endpoints. Once registered, the agent operates as a sovereign actor with its own wallet, signing transactions and negotiating with other agents. You can discover agents by querying the registries directly or through tools like 8004scan.

This is the full stack for the machine economy. ERC-8004 handles trust -- who is this agent, can I trust them. x402 handles payment -- HTTP 402 Payment Required, native machine-to-machine transactions. MCP and A2A handle communication -- standardized protocols for tool use and agent messaging. The end-to-end flow is: discover via A2A, verify via ERC-8004, pay via x402, done. We deploy on L2s like Base, Celo, and Avalanche for sub-cent transaction fees.

Stack is the PerkOS middleware that makes all of this accessible via REST APIs. Instead of writing Solidity or using ethers.js to interact with contracts directly, you just call Stack endpoints. It handles multi-chain routing, ABI encoding, and follows web standards with dot-well-known discovery endpoints. Currently supports 38 networks including all major L2s. Everything you need to integrate ERC-8004 into your application is one HTTP call away.

Let me walk you through the discovery endpoints. The health check confirms Stack is online and returns the API version. The ERC-8004 descriptor at dot-well-known gives you everything about this agent: capabilities, payment methods, supported networks, contract addresses. And llms.txt is specifically designed for AI agents -- it returns plain text instructions that any LLM can parse to understand how to interact with Stack. These are all standard HTTP GET requests, nothing special needed.

Identity lookup returns the registry contract info for any network. The identity registry is an ERC-721 -- each agent is literally an NFT with a tokenURI pointing to its agent card metadata. For reputation, you query by agent ID and get back all on-chain feedback: scores, tags for categorization like fx-trade or buy, which clients gave the feedback, and whether any feedback was revoked. Reputation uses signed int128 so it supports both positive and negative values with configurable decimal precision.

Onboarding is where it gets interesting. One POST request to Stack returns everything your agent needs: the registration transaction ready to sign, x402 payment configuration with the facilitator URL and pay-to address, and the ERC-8004 contract addresses for the chosen network. In production, your agent calls onboard, signs the returned transaction with its wallet, and it's registered on-chain. No dashboard, no manual setup. Fully programmatic.

x402 is the payment layer. The supported endpoint lists all 38 network and scheme combinations. Two schemes: Exact for immediate USDC transfers verified on-chain, and Deferred for escrow-based batch settlement -- useful for high-frequency interactions where settling every single request would be too expensive. The verify endpoint validates a payment proof, and settle executes the on-chain transfer. In production, your server returns HTTP 402 with payment requirements, the client constructs a signed proof, and Stack handles the rest.

Security should scale with risk. A simple query doesn't need the same level of verification as a $10K DeFi operation. ERC-8004 supports this through tiered trust: reputation-only for low stakes, staked collateral for medium, and hardware attestations plus zero-knowledge proofs for critical operations. The key insight is that reputation is portable -- it follows agents across platforms, so bad actors can't just reset their identity.

Now let's get hands-on. We have six exercises that walk through the complete Stack API. Clone the repo, and we'll work through them together. No wallet or private key needed for the read operations -- we're querying live data on Base mainnet.

Setup is simple: Node 18 or higher, npm, and a terminal. No wallet needed for read operations. Just cd into examples/stack-api and run npm install. All six examples are standalone TypeScript files that use native fetch against the production Stack API. No SDK, no dependencies beyond chalk for colored output.

Run the first exercise and you'll see five discovery endpoints in action. The key takeaway here is that a single domain exposes the full agent profile. Any agent or human can discover capabilities, trust scores, and payment terms through standard HTTP requests. This is the foundation of the machine economy -- discoverability without intermediaries.

Exercises 2 and 3 query real on-chain data. The identity lookup shows you the registry contract on Base. The reputation query returns actual feedback for agent ID 1 -- you'll see a score of 85, tagged as an fx-trade buy operation. You can pass your own address or agent ID as arguments. Note the contract addresses are the same across all EVM chains -- they use CREATE2 deterministic deployment.

Exercise 4 shows agent onboarding. When you run this, Stack returns the complete registration package: the transaction to sign, x402 payment config, and registry addresses. In production, an agent would sign this transaction with its wallet and be registered on-chain in one step. This is how we make agent registration zero-friction -- one API call gets you everything.

Exercise 5 demonstrates the x402 payment lifecycle. You'll see the 38 supported network-scheme pairs, the health check with per-network RPC latency, and the verify and settle endpoints. In the workshop we use placeholder data since we're not executing real payments, but the flow is exactly what happens in production. Two schemes: Exact for immediate settlement, Deferred for batched escrow-based settlement.

The final exercise ties it all together. Discover, identity, reputation, onboard -- the complete agent lifecycle in one script. This is what a real integration looks like: you discover an agent, check its identity and reputation before interacting, then register your own agent to participate in the same network. Run it and you'll see the full flow against live production data.

This diagram shows how Stack fits in. Your agent or application makes HTTP requests to Stack, and Stack handles all the blockchain interaction: multi-chain routing across 38 networks, ABI encoding, discovery protocols following web standards, and x402 payment facilitation. For advanced users who want to interact with the contracts directly, we have separate examples using ethers.js in the direct-contract directory.

Here are the contract addresses. Notice they are identical across all seven mainnet chains -- this is thanks to CREATE2 deterministic deployment. One address for Identity, one for Reputation, everywhere. This makes cross-chain agent interoperability straightforward: same agent ID, same contracts, same addresses, any chain.

To recap: ERC-8004 gives agents trustless identity and reputation. x402 gives them native payments. Stack makes it all accessible through simple REST APIs. Discover, verify, pay, repeat. That's the machine economy. Stack is live at stack.perkos.xyz -- go build something.