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.
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
> 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".
READABLE3. REWARDS
Registry contracts map codes to payout addresses, enabling automatic on-chain revenue distribution.
INCENTIVIZEDUnderstanding 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
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:
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
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.
{
"agent_id": "defi-analyzer.eth#0x123...",
"name": "DeFi Research Agent",
"capabilities": ["yield_analysis", "risk_assessment"],
"evm_address": "0x123..."
}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.
{
"ratings": {
"accuracy": 5/5,
"timeliness": 4/5,
"reliability": 5/5
},
"task_id": "task_789"
}Validation Registry
Ensures tasks are executed correctly through cryptographic proofs (zkTLS, TEE attestations) orcrypto-economic validation (restaking, AVSs). Payments only release when validation succeeds.
- zkTLS proofs for API call verification
- TEE attestations for secure computation
- EigenLayer AVS for economic security
The Agent Economy Workflow
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
SCHEMA ID: 0
Optimized for single/multi-entity attribution using the Canonical Code Registry.
- codesLength1 Byte
- codesVariable (ASCII, comma delimited)
07626173656170700080218021802180218021802180218021
Parsing Logic
Extract last 16 bytes. Verify it matches 0x8021...8021.
Extract previous 1 byte as schemaId.
If Schema 0: Extract codesLength then codes.
Parse ASCII codes using 0x2C (comma) delimiter.
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
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.
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.
ATTRIBUTION
ARCHITECTURE
ERC-8021
NATIVE_INTEGRATIONSOLANA
SPL_MEMOBUILT 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.
> STREAMING_PAYMENT_OPEN
M2M_ECONOMY
IoT Bandwidth Markets
5G routers selling bandwidth to passersby. Autonomous cars paying for charging by the second.
> 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.
> X-COST: 0.0004 ETH
Backed By & Building On
Leading infrastructure providers, L2s, and Venture Capital firms accelerating the Attribution Layer.
ECOSYSTEM METRICS
Live data from x402 testnet
THE PLAYGROUND
HANDSHAKE_SIM
See how the 402 error triggers the challenge-response cycle.
1. REQUEST
Client requests a premium resource.
2. CHALLENGE
Server blocks request with 402 status and Price Header.
3. SIGNATURE
Browser wallet signs the challenge (off-chain).
4. ACCESS
Server verifies signature against channel balance.
----------------------------------------
GET /api/v1/article/8021 HTTP/1.1 Host: api.dorksense.io
GAS_SAVER_CALC
Estimate potential savings using x402 channels vs L1 Transactions.
Legacy (L1)
x402 Protocol
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
// 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"
}
}
});// 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.
3. x402 IMPLEMENTATION
How do developers actually use this? You must implement the "Payment Loop" logic in your frontend.
// 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]
> ASK ABOUT ERC-8021 PROTOCOL IMPLEMENTATION.
> WAITING FOR INPUT...