Version 2.0 / January 2025

x8004 Protocol

The Payment Security Layer for ERC-8004 Agents

1. Abstract

x8004 is a comprehensive protocol layer for ERC-8004 agent commerce, providing payment security, dispute resolution, and service discovery infrastructure. Building on x402 payment execution, x8004 adds negotiation, reputation scoring, policy enforcement, escrow with insurance, and decentralized dispute resolution.

The protocol positions itself as "The Payment Security Layer for ERC-8004" - enabling autonomous agents to transact safely with verifiable identity, stake-backed guarantees, and fair dispute resolution through token-staked jurors.

Key innovations in v2.0 include the X8004 governance token, insurance pool with yield generation, onchain negotiation agreements, and a decentralized juror system for dispute arbitration.

2. Problem Statement

The Agent Commerce Problem

AI agents increasingly need to pay for services: APIs, compute, data feeds. ERC-8004 provides verifiable agent identity, and x402 solved payment mechanics. Several problems remained:

  • Budget Control: Agents with payment access can drain funds without controls.
  • Trust: No way to assess provider trustworthiness before committing funds.
  • Price Discovery: Fixed pricing ignores market conditions and agent reputation.
  • Delivery Assurance: Pre-payment exposes agents to fraud.
  • Dispute Resolution: No fair mechanism when service delivery fails.
  • Service Discovery: Agents need to find x402/x8004-enabled services.

Why x402 Alone Is Not Enough

x402 answers "how to pay" but not "whether to pay," "how much," or "what happens when things go wrong." For human-directed transactions, this works. For autonomous agents, the decision and protection layer is missing.

3. Protocol Overview

Architecture

x8004 sits between agent decision logic and x402 payment execution. Payment requests flow through x8004 components before reaching x402:

Agent Request (ERC-8004 Identity)
    |
+--------------------------------------+
|        x8004 Protocol Layer          |
+--------------------------------------+
|  1. Policy Engine (budget check)     |
|  2. Reputation Oracle (trust)        |
|  3. Negotiation Registry (price)     |
|  4. Escrow + Insurance (lock funds)  |
|  5. Dispute Resolver (arbitration)   |
+--------------------------------------+
    |
+--------------------------------------+
|     x402 Payment Execution           |
|   (HTTP 402 + USDC on Base)          |
+--------------------------------------+
    |
Service Delivery

Design Principles

  • ERC-8004 Native: Built for verifiable agent identity integration.
  • x402 Compatibility: x8004 wraps x402, doesn't replace it.
  • Stake-Backed Trust: Service providers stake X8004 tokens as collateral.
  • Decentralized Arbitration: Token-staked jurors resolve disputes fairly.
  • Insurance Coverage: Pooled protection for high-value transactions.

4. Core Components

X8004 Token

ERC20 governance token for staking, fee discounts, and juror participation.

Treasury

Protocol fee collection with token-based discounts.

Policy Engine

Enforces spending rules, budget limits, access controls.

Reputation Oracle

Aggregates trust scores from on-chain transaction history.

Negotiation Registry

Onchain offers and binding agreements with SLA terms.

Escrow Primitive

Holds funds with insurance integration until delivery confirmed.

Dispute Resolver

Token-staked juror system for fair arbitration.

Insurance Pool

Stake X8004 to earn yield; provides coverage for disputes.

Endpoint Registry

Staked service providers with ERC-8004 identity linking.

5. X8004 Token

Token Overview

X8004 is an ERC20 governance token with a fixed supply of 100,000,000 tokens. It serves multiple purposes within the protocol ecosystem.

Token Utility

  • Endpoint Staking: Service providers must stake minimum 1,000 X8004 to register.
  • Juror Staking: Stake 1,000+ X8004 to participate in dispute resolution.
  • Insurance Staking: Stake to earn yield from insurance premiums.
  • Fee Discounts: Pay protocol fees in X8004 for 20% discount.
  • Governance: Vote on protocol parameters and upgrades.

Token Distribution

Total Supply: 100,000,000 X8004

Distribution:
- Protocol Treasury: 30% (30M)
- Team & Advisors:   20% (20M) - 2yr vesting
- Community/Airdrop: 25% (25M)
- Liquidity:         15% (15M)
- Early Backers:     10% (10M) - 1yr vesting

6. Protocol Flow

Complete transaction sequence with v2.0 features:

  1. Request: Agent constructs payment intent with ERC-8004 identity.
  2. Policy Check: Validate against budget, whitelist, time rules.
  3. Reputation Query: Get provider trust score and stake verification.
  4. Negotiation: Check for existing agreement or negotiate new terms.
  5. Escrow Lock: Lock funds with optional insurance premium.
  6. x402 Execution: Execute payment via x402.
  7. Service Delivery: Provider delivers service.
  8. Confirmation: Agent confirms or disputes delivery.
  9. Resolution: Release funds or trigger dispute resolution.

7. Negotiation Protocol

Onchain Agreements

The NegotiationRegistry contract enables binding onchain agreements between agents and service providers with SLA terms.

Offer Structure

struct Offer {
  address endpoint;       // Service provider
  uint256 pricePerCall;   // Price in USDC (6 decimals)
  uint256 slaUptimeBps;   // SLA uptime (e.g., 9950 = 99.50%)
  uint256 slaResponseMs;  // Max response time in ms
  uint256 validUntil;     // Offer expiration
  bool active;
}

struct Agreement {
  address agent;
  uint256 offerId;
  uint256 acceptedAt;
  uint256 expiresAt;      // Max 90 days
  bool active;
}

Agreement Flow

  • Endpoint publishes offer with price and SLA terms
  • Agent accepts offer, creating binding agreement
  • Agreement referenced in escrow deposits
  • SLA violations can trigger disputes

8. Reputation Oracle

Overview

Trust scores for all participants. Scores 0-100, computed from on-chain transaction history using time-weighted algorithm.

Score Components

  • Completion Rate: Percentage of successful transactions.
  • Dispute Rate: Frequency of disputes (weighted heavily).
  • Volume: Total transaction volume (log-scaled).
  • Stake Amount: Higher stakes indicate commitment.
  • Longevity: Time since first interaction.

Slashing Threshold

Endpoints with reputation score below 50 are subject to automatic slashing of 10% of their stake. This creates strong incentives for quality service delivery.

9. Policy Engine

Purpose

Enforces spending rules defined by agent owner. Prevents unauthorized or excessive spending.

Policy Schema

interface AgentPolicy {
  budget: {
    daily: USDC;
    weekly: USDC;
    monthly: USDC;
    perTransaction: USDC;
  };
  whitelist: string[];
  blacklist: string[];
  activeHours?: { start: number; end: number };
  approvalRequired: { above: USDC };
  minProviderScore: number;
  requireInsurance: boolean;
  requireAgreement: boolean;
}

10. Escrow Primitive

Overview

EscrowV2 smart contract on Base holds funds until delivery confirmation. Integrates with Treasury for fees, InsurancePool for coverage, and DisputeResolver for arbitration.

Payment States

  • DEPOSITED: Funds locked, awaiting delivery.
  • RELEASED: Agent confirmed, funds sent to provider.
  • DISPUTED: Agent disputed, awaiting juror resolution.
  • REFUNDED: Dispute resolved in agent's favor.
  • CLAIMED: Timeout reached, provider claimed funds.
  • RESOLVED: Dispute resolved by jurors.

Fee Structure

Deposit with fees:
- Base Amount:     $100.00 USDC
- Protocol Fee:    $0.10 (0.1%)
- Insurance:       $0.50 (0.5%) - optional
- Total:           $100.60 USDC

Pay fee in X8004 for 20% discount:
- Protocol Fee:    $0.08 worth of X8004

11. Dispute Resolution

Token-Staked Juror System

The DisputeResolver contract implements decentralized arbitration through token-staked jurors. This ensures fair, unbiased resolution of disputes between agents and service providers.

Juror Requirements

  • Minimum Stake: 1,000 X8004 tokens
  • Unstake Cooldown: 7 days
  • Selection: Pseudo-random from eligible pool

Dispute Flow

1. Agent opens dispute with evidence URI
2. 5 jurors randomly selected from pool
3. 72-hour voting window begins
4. Jurors vote: Release (to endpoint) or Refund (to agent)
5. Simple majority determines outcome
6. Winners: 2% of disputed amount split as reward
7. Losers: 5% of stake slashed

Incentive Alignment

Jurors are incentivized to vote honestly through the reward/slash mechanism. Voting with the majority earns rewards; voting against loses stake. This creates strong game-theoretic incentives for fair resolution.

12. Insurance Pool

Overview

The InsurancePool contract allows X8004 holders to stake tokens and earn yield from insurance premiums collected during escrow deposits.

Staking Mechanics

  • Minimum Stake: 100 X8004
  • Premium Rate: 0.5% of escrow amount
  • Yield Distribution: Pro-rata based on stake amount
  • Unstake Cooldown: 3 days

Coverage Limits

Max Coverage Per Claim: 10% of pool balance

Example:
- Pool Balance: $500,000 USDC
- Max Single Claim: $50,000 USDC

Coverage triggers:
- Dispute resolved in agent's favor
- Provider stake insufficient for refund

13. Treasury & Fees

Fee Schedule

Fee TypeRateWith X8004
Escrow Fee0.1%0.08%
Dispute Fee2.0%1.6%
Insurance Premium0.5%0.5%
Negotiation Fee0.05%0.04%

Treasury Distribution

  • Protocol Development: 40%
  • Insurance Pool Reserve: 30%
  • Staker Rewards: 20%
  • Community Grants: 10%

14. Service Discovery

Endpoint Registry V2

Enhanced on-chain directory with staking requirements and ERC-8004 identity linking.

Registration Requirements

  • Minimum Stake: 1,000 X8004
  • ERC-8004 Token: Optional identity linking
  • Metadata URI: IPFS link to service description
  • Categories: Data, AI, Compute, Storage, Oracle, Custom
  • Price Tiers: Multiple pricing options with SLA

Query Example

const services = await registry.search({
  category: 'AI',
  minReputation: 80,
  minStake: 5000,
  maxPrice: 1.00,
});

// Returns endpoints with:
// - Staked amount and stake status
// - Reputation score and history
// - Price tiers and SLA terms
// - ERC-8004 identity if linked

15. Security Model

Threat Model

  • Agent compromise
  • Provider fraud
  • Reputation manipulation
  • Juror collusion
  • Insurance pool attacks
  • Smart contract exploits

Mitigations

  • Policy Enforcement: Limits damage from compromised agents.
  • Stake Requirements: Economic cost for bad behavior.
  • Random Juror Selection: Prevents targeted collusion.
  • Slashing Mechanism: Punishes dishonest jurors and providers.
  • Coverage Limits: Caps insurance exposure per claim.
  • Cooldown Periods: Prevents flash attacks on pools.
  • Audit Trail: All transactions recorded on-chain.

16. Economic Model

Value Accrual

X8004 token captures value through multiple mechanisms:

  • Staking Demand: Required for endpoints, jurors, insurance.
  • Fee Burns: Portion of fees used for token buyback.
  • Yield Generation: Insurance stakers earn real yield.
  • Governance Rights: Protocol parameter control.

Projected Economics

At $10M monthly escrow volume:
- Escrow Fees:    $10,000/month (0.1%)
- Insurance:      $50,000/month (0.5%)
- Dispute Fees:   $2,000/month (estimated)

Insurance Pool APY at 10% utilization:
- Premium Income: $50,000/month
- Stakers Yield:  ~8-12% APY

17. Roadmap

Q1 2025 Current

  • Core Protocol V2 on Base
  • X8004 Token Launch
  • Escrow + Insurance
  • Dispute Resolution System
  • TypeScript SDK V2

Q2 2025

  • Agent Marketplace Launch
  • ERC-8004 Deep Integration
  • Mobile SDK
  • Governance Launch

Q3 2025

  • Cross-chain Expansion
  • Advanced Analytics
  • API Aggregator
  • Enterprise Features

Q4 2025

  • Full DAO Transition
  • L2 Optimizations
  • Institutional Partnerships

References

  1. [1] x402 Protocol. x402.org
  2. [2] ERC-8004: Agent Identity Standard
  3. [3] Base Network. docs.base.org
  4. [4] USDC. centre.io/usdc
  5. [5] HTTP 402. RFC 7231, Section 6.5.2
  6. [6] OpenZeppelin Contracts. openzeppelin.com/contracts