-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add x402 protocol volume adapter for Base #4582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Tracks USDC payment volume through 36 x402 facilitator addresses across 11 providers on Base chain. - Detects x402 transactions via AuthorizationUsed events (EIP-3009) - Multi-path fallback for different RPC capabilities - Respects per-facilitator start dates - SimpleAdapter v2 compatible - Start date: 2024-12-05
|
The x402 adapter exports: |
| // Intersect with USDC Transfers to get amounts | ||
| if (allowedHashes.size) { | ||
| const TRANSFER_EVENT = "event Transfer(address indexed from, address indexed to, uint256 value)"; | ||
| const transferLogs: any[] = await options.getLogs({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pulling all transfers of usdc on base is gonna be extremely slow and resource intensive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we won't allow it. I'm looking for other solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now the adapter is already kind of hybrid in practice:
- it relies on ~36 facilitators collected from external x402 sources (ecosystem docs, explorers, etc.),
- but the implementation has been trying to behave as if a globally pure USDC view was possible by effectively walking all USDC activity and filtering afterwards.
In practice, trying to brute-force all USDC traffic from inside a single adapter doesn’t seem to work well in this context. Getting a fully protocol-pure view might need a separate indexer for USDC/EIP-3009 flows on Base, but even with an indexer there would still need to be some source of truth for which addresses are x402 facilitators (either a curated list like now, or a future on-chain registry), and that part sits outside what an adapter is usually meant to handle.
A more realistic approach within this stack might be:
- make it explicit that the metric is facilitator-scoped (a curated
FACILITATORS_SET), - for that subset, try to keep the accounting strictly on-chain:
AuthorizationUsedon USDC(Base),- receipts,
- USDC
Transferamounts,
- and avoid full-token scans on USDC.
Looking forward, if agent payments on Base keep growing around x402 and things like Google’s AP2, it probably won’t be realistic long term to maintain facilitator lists by hand. On top of that, more decentralised/permissionless facilitators are likely to show up, and individual agents will tend to use multiple addresses and multiple facilitators over time. Without some shared way to categorise and publish that mapping, it becomes very hard to keep any view of the system coherent. Standards in the ERC-8004 direction explicitly aim at on-chain agent/service registries, so if that kind of registry ends up being the decentralised way to publish which addresses are agents/services/facilitators, the adapter could eventually be updated to derive its facilitator set from there (or from an indexer built on top of it) instead of hard-coding addresses. Until that layer is mature and there is a clean on-chain way to discover all relevant facilitators, the hybrid approach (curated facilitators + pure accounting over that subset) might be the practical option.
DefiLlama adapter for tracking x402 payment protocol volume on Base.
What is x402?
x402 is a payment protocol enabling USDC payments to AI agents using Account Abstraction and EIP-3009 (
transferWithAuthorization) on Base L2.Links:
What This Adapter Tracks
Metrics Returned:
Coverage: Tracks 36 facilitator addresses across 11 providers (Coinbase, PayAI, Questflow, x402rs, Codenut, Aurracloud, OpenX402, Daydreams, Mogami, Thirdweb, 402104, XEcho) on Base.
Start Date: December 5, 2024 (earliest facilitator)
Why Fees/Revenue = 0?
Transferevents show full payment amounts (user → AI agent) with no visible deduction✅ dailyVolume is accurate: Total USDC transferred through x402 facilitators is precisely measured
Technical Implementation
Detection Method
Why Track by Sender (tx.from)?
Challenge:
Solution:
Alternative Approach (Future Enhancement):
A separate adapter could track individual AI agent volumes by recipient address (tx.to):
Event Signatures
AuthorizationUsed (EIP-3009):
Transfer (ERC-20):
Multi-Path Fallback
The adapter uses multiple paths for different RPC capabilities:
getTxReceiptsto get full transaction datagetTransactionswhen receipts unavailableTesting
Verified Dates:
Code Structure
Single file:
fees/x402/index.ts(~210 lines)Methodology Statement
Volume: USDC payment volume facilitated through x402 protocol on Base. Tracks transfers from authorized facilitator addresses (36 addresses across 11 providers) using EIP-3009. Respects dateOfFirstTransaction for each facilitator address.
Fees: x402 protocol does not charge user fees on-chain. All payment amounts go directly to recipients. Facilitators may charge fees off-chain.
Revenue: Protocol does not collect direct revenue from transactions. Revenue model is not public.
Data Accuracy
High confidence:
Limitations: