ERC-8004

Trustless Agents — On-chain identity, reputation, and validation for the agentic economy.

Identity

ERC-721 NFT-based agent registration. Each agent gets a unique on-chain identity with metadata and wallet binding.

Reputation

On-chain feedback system (0-100 scores). Payment-backed reviews ensure only verified users contribute trust signals.

Validation

High-value transaction verification. Third-party validators can approve or reject requests before settlement.

What is ERC-8004?

ERC-8004 is the Ethereum standard for Trustless AI Agents. It provides three on-chain registries that enable agents to discover, authenticate, and build trust without centralized intermediaries.

Unlike traditional API keys or OAuth, ERC-8004 identity is self-sovereign. Agents own their identity as an NFT, accumulate reputation through verified interactions, and can request third-party validation for high-stakes operations.

P402 implements ERC-8004 on Base L2, where the Identity and Reputation registries are deployed at production-ready contract addresses.

Contract Addresses

# Base Mainnet (Chain ID: 8453)
Identity Registry: 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
Reputation Registry: 0x8004BAa17C55a88189AE136b182e5fdA19dE9b63
# Base Sepolia Testnet
Identity Registry: 0x8004A818BFB912233c491871b3d84c89A494BD9e
Reputation Registry: 0x8004B663056A597Dffe9eCcC1965A193B7388713

How P402 Uses ERC-8004

Agent Registration File

P402 serves an ERC-8004 Agent Registration File at /.well-known/erc8004.json that describes its identity, services, and supported trust models.

{
  "type": "erc8004-agent-v1",
  "agentId": "<ERC8004_AGENT_ID>",
  "services": ["payment-routing", "ai-settlement"],
  "registrations": [{
    "chain": "base",
    "registry": "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432"
  }],
  "supportedTrust": ["reputation", "validation"]
}

Reputation-Aware Routing

The routing engine factors on-chain reputation into facilitator scoring. Verified agents receive a +25 point bonus, and reputation scores (0-100) add up to +/-25 points to the routing decision. Scores are cached locally with a 5-minute TTL to avoid per-request RPC calls.

Payment-Backed Feedback

After every successful x402 settlement, P402 automatically queues on-chain reputation feedback. Only verified payers can contribute trust signals — the settlement txHash serves as proof of interaction. Feedback is batch-submitted to reduce gas costs.

Validation Guards

High-value transactions (default threshold: $100) trigger the Validation Registry. Third-party validators can approve or reject requests before settlement proceeds, adding an extra layer of trust for large transfers.

x402 + A2A + ERC-8004

Three protocols, one user journey.

01
A2ADiscovery

Agent publishes agent.json + erc8004.json. Peers discover capabilities and trust level.

02
ERC-8004Identity Check

Router verifies facilitator's on-chain identity and reputation before selection.

03
x402Settlement

EIP-3009 gasless USDC transfer executes. Payment proof generated on-chain.

04
ERC-8004Feedback

Settlement proof triggers reputation feedback. Only verified payers build trust.

05
ERC-8004Validation

High-value txs go through Validation Registry before settlement (optional).

API Reference

GET /api/v1/erc8004/reputation

Returns ERC-8004 reputation data for all registered facilitators.

// Response
{
  "facilitators": [
    {
      "facilitator_id": "abc-123",
      "name": "Acme Settlement",
      "erc8004_agent_id": "42",
      "erc8004_verified": true,
      "erc8004_reputation_cached": 87
    }
  ]
}

GET /api/v1/erc8004/feedback

Returns feedback history, optionally filtered by facilitator.

// GET /api/v1/erc8004/feedback?facilitatorId=abc-123
{
  "feedback": [
    {
      "id": 1,
      "facilitator_id": "abc-123",
      "value": 85,
      "status": "submitted",
      "created_at": "2025-01-15T10:30:00Z"
    }
  ]
}

POST /api/v1/erc8004/validate

Submit a validation response for a pending high-value transaction.

// Request
{
  "requestHash": "0xabc...",
  "response": true,
  "responseUri": "https://validator.example.com/proof/123",
  "tag": "approved"
}

// Response
{
  "success": true,
  "requestHash": "0xabc...",
  "status": "validated"
}

Configuration

# .env configuration

# Your agent's registered ID (from registration script)
ERC8004_AGENT_ID=42

# Agent metadata URI
ERC8004_AGENT_URI=https://p402.io/.well-known/erc8004.json

# Use Base Sepolia testnet instead of mainnet
ERC8004_TESTNET=false

# Enable reputation-aware routing and feedback
ERC8004_ENABLE_REPUTATION=true

# Enable validation guards for high-value txs
ERC8004_ENABLE_VALIDATION=true

# Validation threshold in USD (default: 100)
ERC8004_VALIDATION_THRESHOLD_USD=100