THE NATIVE
ATTRIBUTIONPROTOCOL

ERC-8021 is a standardized method for attributing transactions to applications through data suffixes. It enables interoperable tracking and reward distribution on Ethereum.

ETH MAGICIANS
DECENTRALIZED ///ERC-8021 ///HTTP-402 ///PAYMENT REQUIRED ///STATE CHANNELS ///NO MIDDLEMEN ///ZERO ADS ///
DECENTRALIZED ///ERC-8021 ///HTTP-402 ///PAYMENT REQUIRED ///STATE CHANNELS ///NO MIDDLEMEN ///ZERO ADS ///
CORE STANDARD

ERC-8021

Standardized Data Suffixes

Authors: Conner Swenberg (@ilikesymmetry)
Status: Draft

Goal: Replace ad-hoc attribution with a structured, interoperable standard that supports multiple entities and reward distribution.

1. STRUCTURE

> TX_DATA + SUFFIX
> SCHEMA_ID (1 byte)
> ERC_MARKER (16 bytes)

A strictly defined suffix format appended to transaction calldata, allowing parsers to work backwards from the end.

2. IDENTITY

Entities are identified by "codes" (ASCII strings) rather than opaque hashes. e.g., "baseapp", "morpho".

READABLE

3. REWARDS

Registry contracts map codes to payout addresses, enabling automatic on-chain revenue distribution.

INCENTIVIZED
COMPREHENSIVE GUIDE

Understanding ERC-8021, x402, and ERC-8004: The Future of Ethereum Payments

The Ethereum ecosystem is evolving beyond simple token transfers and smart contract interactions. ERC-8021, combined with the x402 protocol and ERC-8004 agent standard, represents a paradigm shift in how we attribute transactions, process micropayments, and enable autonomous AI agents on the blockchain.

This comprehensive guide explores the technical architecture, use cases, and revolutionary potential of these interconnected standards that are reshaping the Web3 payment infrastructure and creating new economic models for the decentralized internet.

01ERC-8021: Transaction Attribution Standard

ERC-8021 solves a fundamental problem in blockchain ecosystems: how do we properly attribute value creation to the applications, wallets, and infrastructure providers that facilitate transactions? Traditional blockchain transactions contain no standardized way to identify which application initiated them, making it impossible to fairly distribute rewards or track usage analytics.

The Problem ERC-8021 Solves

  • Opaque Attribution: Before ERC-8021, applications used ad-hoc methods (custom events, off-chain tracking) to identify transaction sources, leading to fragmentation and unreliable data.
  • No Revenue Sharing: Without standardized attribution, protocols couldn't automatically distribute fees to the applications that brought users to their platform.
  • Limited Analytics: Developers had no reliable way to measure actual usage, user acquisition costs, or conversion metrics on-chain.

How ERC-8021 Works: Technical Architecture

ERC-8021 introduces a data suffix structure that gets appended to transaction calldata. This suffix contains:

Schema ID (1 byte)

Identifies which attribution schema is being used, allowing for multiple formats and future extensibility.

Entity Codes (Variable)

Human-readable ASCII strings (e.g., "baseapp", "morpho") that identify the applications or entities involved.

Registry Reference (Optional)

For custom schemas, points to a specific registry contract that maps codes to payout addresses.

ERC Marker (16 bytes)

Fixed identifier (0x8021...8021) that allows parsers to work backwards from the end of calldata.

This backward-parsing approach is crucial: it means any existing smart contract can support ERC-8021 attribution without modification. The contract executes normally, and attribution data is extracted by off-chain indexers and specialized registry contracts.

Real-World Impact

With ERC-8021, a DeFi protocol can automatically distribute 10% of fees to the wallet or aggregator that brought the user. An NFT marketplace can reward the platform where a user discovered the collection. A lending protocol can compensate the analytics dashboard that helped users find the best rates. This creates a sustainable incentive structure for the entire Ethereum ecosystem.

02x402 Protocol: HTTP 402 for Blockchain

The x402 protocol brings the long-dormant HTTP 402 status code ("Payment Required") to life on the blockchain. It enables high-frequency micropayments without gas fees through cryptographic state channels, revolutionizing how we pay for digital services.

Why Traditional Blockchain Payments Fail for Micropayments

$0.50+
Average L1 gas fee per transaction
12s
Block confirmation time
$0.0001
Typical API call value

The Problem: When the transaction fee is 5,000x the value being transferred, micropayments become economically impossible.

x402 Solution: Off-Chain State Channels

x402 uses unidirectional payment channels with cryptographic signatures to enable thousands of micropayments off-chain, settling only the final state on-chain. Here's how it works:

STEP 1:User locks funds in a smart contract (e.g., 1 ETH)
STEP 2:Service provider sends HTTP 402 response with payment details
STEP 3:User signs a message: "I authorize 0.0001 ETH to Provider"
STEP 4:Provider verifies signature and delivers content/service
STEP 5:Repeat steps 2-4 thousands of times (all off-chain, zero gas)
STEP 6:Provider submits final signature to smart contract for settlement

Key Benefits of x402

Zero Gas Fees

All micropayments happen off-chain via signatures. Only the final settlement costs gas.

Trustless Security

Cryptographic signatures ensure providers can't take more than authorized. Users can withdraw after timeout.

Instant Settlement

Payments are verified in milliseconds, not minutes. Perfect for streaming content or API calls.

Blockchain Agnostic

Works on any EVM chain. Can be adapted for cross-chain atomic swaps.

Use Cases Unlocked by x402

  • AI Agent Payments: Autonomous agents paying $0.0001 per LLM token, $0.001 per API call, or $0.01 per minute of compute time—all without human intervention.
  • Content Micropayments: Pay $0.02 to read one article, $0.05 to watch 10 minutes of video, $0.001 per song stream—no subscriptions, no ads, no tracking.
  • Cloud Services: Pay-per-use for storage (per GB-hour), bandwidth (per MB), compute (per CPU-second)— true serverless economics.
  • IoT & M2M Economy: Devices paying each other for services—5G routers selling bandwidth, electric vehicles paying for charging by the second.

03ERC-8004: On-Chain AI Agent Standard

ERC-8004 extends Google's Agent-to-Agent (A2A) protocol for the blockchain era, creating a trustless framework for autonomous AI agents to discover each other, build reputation, and exchange value on Ethereum.

The Three Core Registries

1
Identity Registry

Agents register their Agent Card on-chain, containing metadata like name, description, capabilities, and EVM address. This creates a universal, verifiable identity that works across applications and chains.

Example Agent Card:
{ "agent_id": "defi-analyzer.eth#0x123...", "name": "DeFi Research Agent", "capabilities": ["yield_analysis", "risk_assessment"], "evm_address": "0x123..." }
2
Reputation Registry

After task completion, client agents submit structured feedback about server agents. This creates an immutable, on-chain reputation system—like Yelp for AI agents, but cryptographically verifiable.

Feedback Structure:
{ "ratings": { "accuracy": 5/5, "timeliness": 4/5, "reliability": 5/5 }, "task_id": "task_789" }
3
Validation Registry

Ensures tasks are executed correctly through cryptographic proofs (zkTLS, TEE attestations) orcrypto-economic validation (restaking, AVSs). Payments only release when validation succeeds.

Validation Methods:
  • zkTLS proofs for API call verification
  • TEE attestations for secure computation
  • EigenLayer AVS for economic security

The Agent Economy Workflow

DISCOVERY:Client agent searches Identity Registry for agents with "DeFi analysis" capability
SELECTION:Reviews Reputation Registry, finds agent with 4.8/5 rating and 500+ completed tasks
EXECUTION:Server agent performs analysis, publishes data hash commitment on-chain
VALIDATION:Validator verifies work via zkTLS proof, posts Validation Response
SETTLEMENT:Smart contract releases payment (via x402 channel), client submits feedback

Getting Started: Integration Guide

For Developers

Integrate ERC-8021 attribution in your dApp with minimal code changes. Add x402 payment channels for micropayments.

View Integration Docs →

For Protocols

Implement revenue sharing with applications that bring users. Track attribution analytics on-chain.

View Protocol Specs →

For AI Builders

Register your AI agents on ERC-8004, build reputation, and participate in the autonomous economy.

Explore ERC-8004 →

Technical Specs

> Data Suffix Structure

Original Calldata
...TX_DATA
Schema Data
[CODES_LEN][CODES]
Schema ID
1 Byte
ERC Identifier
16 Bytes
(0x8021...8021)
<< SCROLL TO VIEW >>

SCHEMA ID: 0

Optimized for single/multi-entity attribution using the Canonical Code Registry.

  • codesLength1 Byte
  • codesVariable (ASCII, comma delimited)
Example Suffix:
07626173656170700080218021802180218021802180218021

Parsing Logic

1

Extract last 16 bytes. Verify it matches 0x8021...8021.

2

Extract previous 1 byte as schemaId.

3

If Schema 0: Extract codesLength then codes.

4

Parse ASCII codes using 0x2C (comma) delimiter.

// Registry Interface
function payoutAddress(string memory code) external view returns (address);

The Mesh Gateway

ERC-8004 works in tandem with 8021. It allows any node to act as a re-broadcaster.

  • Decentralized CDN functionality
  • Route payments to content creators + node operators
  • Censorship resistant propogation
ERC-8004

CONTENT
ROUTING

While 8021 handles the payment, ERC-8004 handles the routing. It defines how content is addressed (via content-hash) and how payment is split between the Creator and the Relay Node.

OPCODE::0x5F

x402

The atomic execution unit. The heartbeat of the protocol.

GAS EFFICIENCY

x402 minimizes on-chain storage. It only verifies the Compact Signature. Standard transfer cost: 21,000 gas. x402 Channel Update: 4,500 gas (virtual).

ATOMIC SWAPS

Supports cross-chain settlements via HTLCs (Hash Time Locked Contracts) integrated directly into the opcode logic.

EVM_STACK_VISUALIZER
STACK[0]
0x...ChannelID
STACK[1]
0x...Signature
STACK[2]
0x...Amount
> PUSH1 0x402
> VERIFY_SIG
> STATE_UPDATE_SUCCESS
PROTOCOL_WARS

ATTRIBUTION
ARCHITECTURE

Ξ

ERC-8021

NATIVE_INTEGRATION
TX_DATAREF:BASE_APP
WAITING...
S

SOLANA

SPL_MEMO
TX_DATA
MEMO:REF
WAITING...
Protocol_Debugger
Waiting for input...
ADOPTION LAYER

BUILT ON x402

Developers are using Conditional Asset Streaming to invent new business models. The API economy is shifting from monthly subscriptions to per-call value.

AI_AGENTS

Pay-Per-Inference

Stop paying $20/mo for APIs you use twice. x402 enables agents to pay 0.00001 ETH per LLM token generated.

> AGENT_WALLET_AUTOSIGN
> STREAMING_PAYMENT_OPEN

M2M_ECONOMY

IoT Bandwidth Markets

5G routers selling bandwidth to passersby. Autonomous cars paying for charging by the second.

> DEVICE_ID: 5G_NODE_A
> REVENUE: 4.2 ETH/MO

ZERO_AD_MEDIA

Content Unbundling

Read one article for $0.05. Watch 10 mins of video for $0.02. No login. No paywalls. No ads tracking you.

> STATUS: 200 OK
> X-COST: 0.0004 ETH

Backed By & Building On

Leading infrastructure providers, L2s, and Venture Capital firms accelerating the Attribution Layer.

BASE
OPTIMISM
PARADIGM
HYPERLIQUID
PRIVY
FLASHBOTS
VERCEL
STRIPE

ECOSYSTEM METRICS

Live data from x402 testnet

50+
Dapps Integrated
$2.4M
TVL In Channels
12ms
Settlement Time
INTERACTIVE

THE PLAYGROUND

HANDSHAKE_SIM

See how the 402 error triggers the challenge-response cycle.

1

1. REQUEST

Client requests a premium resource.

2

2. CHALLENGE

Server blocks request with 402 status and Price Header.

3

3. SIGNATURE

Browser wallet signs the challenge (off-chain).

4

4. ACCESS

Server verifies signature against channel balance.

network_inspector
$ GET /premium-content
----------------------------------------
GET /api/v1/article/8021 HTTP/1.1 Host: api.dorksense.io

GAS_SAVER_CALC

Estimate potential savings using x402 channels vs L1 Transactions.

1 TX1000 TXs

Legacy (L1)

$12.60
0.0042 ETH

x402 Protocol

$6.00
0.0020 ETH
Total Savings
SAVE 52%
BUILD ///SHIP ///MONETIZE ///REPEAT ///OPEN SOURCE ///PURE VALUE ///GASLESS ///
BUILD ///SHIP ///MONETIZE ///REPEAT ///OPEN SOURCE ///PURE VALUE ///GASLESS ///

Integrate Now

1. WALLET INTEGRATION

Use ERC-5792 wallet_sendCalls with the new DataSuffixCapability to append attribution data cleanly.

  • Standardized Suffix Appending
  • Separates App Logic from Wallet Logic
protocol_v2.sol
// ERC-5792 Capability Interface
interface DataSuffixCapability {
  // Hex-encoded bytes to append
  dataSuffix: string; 
}

// Usage with Wallet
await wallet.sendCalls({
  calls: [...],
  capabilities: {
    dataSuffix: {
      // Suffix for "baseapp"
      dataSuffix: "0x...8021"
    }
  }
});
protocol_v2.sol
// ERC-4337 Implementation Note:
// For Smart Accounts, append suffix to
// userOp.callData instead of tx.data

const userOp = {
  sender: "0x...",
  nonce: "0x...",
  // Append 8021 suffix here
  callData: "0x...[SUFFIX]", 
  ...
}

2. SMART ACCOUNTS

For ERC-4337 (Account Abstraction), the attribution suffix must be appended to the userOp.callData, ensuring the EntryPoint contract executes it correctly.

READ ERC-4337 SPEC
CRITICAL

3. x402 IMPLEMENTATION

How do developers actually use this? You must implement the "Payment Loop" logic in your frontend.

STEP 1Request Resource (GET /api)
STEP 2Catch 402 Error + 'X-Challenge'
STEP 3Sign Challenge with Wallet
STEP 4Retry with 'Authorization' Header
protocol_v2.sol
// x402 Client-Side Middleware
const fetchResource = async (url) => {
  const res = await fetch(url);
  
  // 1. INTERCEPT 402
  if (res.status === 402) {
    const challenge = res.headers.get('X-Challenge');
    
    // 2. SIGN CHALLENGE
    const signature = await wallet.sign(challenge);
    
    // 3. RETRY WITH AUTH
    return await fetch(url, {
      headers: { 'Authorization': `ETH-SIG ${signature}` }
    });
  }
  return res;
};

DORK_ORACLE

ASK ANYTHING ABOUT ERC-8021, x402, or 8004

DORKSENSE_ORACLE [AI]

> SYSTEM READY.
> ASK ABOUT ERC-8021 PROTOCOL IMPLEMENTATION.
> WAITING FOR INPUT...