Scenario 1
An agent buys one API call
A client agent finds a paid weather endpoint through the x402 Bazaar or an ERC-8004 registration, pays for one call with x402 V2 exact, and leaves ERC-8004 feedback whose proof of payment sits in an off-chain file.
The situation
A research needs the current weather for one city, once. No human is present: the agent’s owner gave it a wallet and a spending policy in advance, and the agent decides on its own whether a call is worth paying for. The seller is a small API that charges per request and has no sign-up form. Two protocols cover the job. x402 moves the money inside the HTTP request, and ERC-8004 gives the seller an on-chain identity and gives the buyer a public place to say how the call went.Source [1, 2] Neither protocol depends on the other: ERC-8004 treats payment as out of scope, but its has an x402Support flag and its can point to an x402 payment.Source [3]
Actors
- Client with a wallet that can sign typed data (the buyer).
- Seller , the weather API, which also owns an ERC-8004 agent identity.
- , which verifies and settles x402 payments and does not hold funds.Source [1, 4, 5]
- discovery endpoint, a facilitator’s public catalog of paid resources.Source [4]
- ERC-8004 Identity and Reputation Registries, singleton contracts that use the same addresses on every listed mainnet.Source [6]
- Storage host (IPFS or HTTPS) for the and the .
- Readers: indexers, explorers and later buyers.
Step by step
- Discover (x402, path A). The client calls
GET /discovery/resourceson a and gets listings withresource,type,x402Version,acceptsandlastUpdated.Source [4] The CDP instance answers without an API key, but it returns listings, not categories.Source [7] - Discover (ERC-8004, path B). The client reads the seller’s
agentURIandagentWalletfrom the Identity Registry.agentWalletis where the receives payments, and setting it needs a signature from the new wallet.Source [2] - Read the (ERC-8004). The file lists
services,x402Support,activeandregistrations.Source [2] An agent can prove control of its endpoint domain with a/.well-known/agent-registration.jsonfile.Source [2] - Request (x402). The client calls the endpoint with no payment header and learns the price from the reply.Source [4, 8]
- (x402). The server answers 402 with a
PAYMENT-REQUIREDheader holding base64 JSON.Source [4, 8] Eachacceptsentry namesscheme,network,amount,asset,payToandmaxTimeoutSeconds.Source [4] - Check and sign (x402). The client signs typed data for
TransferWithAuthorization.Source [9] ERC-8004 best practice is to useagentWalletas the x402 receipt address, so a careful client comparespayTowith it before signing.Source [10] - Retry (x402). The same request goes out again with a base64
PaymentPayloadinPAYMENT-SIGNATURE.Source [8] - Verify and run (x402). The server calls
POST /verify, runs the handler only if the payment is valid, then callsPOST /settle.Source [4] - Settle (x402).
/settleuses the same request body as/verifyand commits the payment.Source [4] - On chain (x402). On EVM chains the broadcasts the EIP-3009 settlement and pays the gas.Source [5, 11] The signature binds amount and recipient, so the facilitator cannot redirect funds.Source [9]
- Response (x402). The server returns 200 with a
PAYMENT-RESPONSEheader holding theSettleResponse, which includes thetransactionhash.Source [4, 8] - Publish (ERC-8004). The client writes the file with the required
agentRegistry,agentId,clientAddress,createdAt,valueandvalueDecimals, plusproofOfPaymentwithfromAddress,toAddress,chainIdandtxHash.Source [2] The file comes first.Source [2] - Give feedback (ERC-8004). The client calls
giveFeedback(agentId, value, valueDecimals, tag1, tag2, endpoint, feedbackURI, feedbackHash).Source [2] The registry stores onlyvalue,valueDecimals,tag1,tag2andisRevoked.Source [2, 12] - Check the proof (ERC-8004 readers). A reader fetches the file from
feedbackURI, comparesfeedbackHash, and looks uptxHash. The registry never verifies the proof.Source [2, 12]
Which protocol does what
| Steps | Protocol | Object or message | Spec version |
|---|---|---|---|
| 1 | x402 | GET /discovery/resources () | V2.0 |
| 2 to 3 | ERC-8004 | agentURI, getAgentWallet, | Draft, text of 2026-01-25 |
| 4 to 11 | x402 | PAYMENT-REQUIRED, PAYMENT-SIGNATURE, /verify, /settle, PAYMENT-RESPONSE | V2.0, on EVM |
| 12 to 14 | ERC-8004 | with proofOfPayment, giveFeedback, NewFeedback | Draft, text of 2026-01-25 |
x402 V2.0 is dated 2025-12-09 in the specification’s version table.Source [4] ERC-8004 is still a Draft, and its last specification change before 2026-10-11 was on 2026-01-25.Source [2, 13, 14, 15]
Where controls apply
- Before authorization. Client policy decides whether to pay. The TypeScript SDK applies
spendControlsby default: default assets only and at most $1 per payment.Source [16, 17] Budgets beyond that are out of scope for x402 and live in SDKs and wallets.Source [4, 18] A controls layer can also require a minimum ERC-8004 score from reviewers it trusts.Source [12] - At signing. Short
validAfterandvalidBeforewindows bound what a signature can do.Source [4] ReadinggetAgentWalletjust before signing catches a transferred , because a transfer clearsagentWallet.Source [2, 19] - At the edge. Payment middleware or a CDN gateway sees every request before the handler.Source [20] Matching the serving domain against the and its
/.well-knownfile is the ERC-8004 edge check.Source [2] - At settlement. x402 has no sanctions layer of its own; the CDP runs OFAC and Know Your Transaction checks.Source [21, 22] SDK hooks such as
onBeforeSettlelet the server act before money moves.Source [18] - After the fact. The and
giveFeedbackare the record. A controls layer should score only feedback whosetxHashresolves to a transfer to the agent’sagentWallet, because the registry checks none of it.Source [2, 12]
What is observable from outside
On chain, an payment shows only the token’s own Transfer and AuthorizationUsed events, so nothing marks it as x402.Source [9, 10, 23] The NewFeedback event carries agentId, clientAddress, feedbackIndex, value, valueDecimals, the tags, endpoint, feedbackURI and feedbackHash; the last three exist on chain only in that event.Source [2] Agent0 subgraphs on The Graph index Registered, MetadataSet, NewFeedback and FeedbackRevoked.Source [24] Once published, the lets anyone join the review to the payment through txHash.Source [2]
What stays private: the exchange itself. Resource URLs, descriptions and amounts in x402 headers travel only between client, server and .Source [4, 25] On-chain pointers and hashes cannot be deleted, so personal data does not belong in a feedback file.Source [2]
What can go wrong
- Verification fails. Errors such as
insufficient_fundsorinvalid_exact_evm_payload_signaturestop the call before the handler runs.Source [4] Nobody loses money. - Settle times out. The outcome is indeterminate:
settlement_pendingis non-terminal and the server must reconcile before retrying.Source [4, 5] The seller carries the risk of serving data it may not be paid for. - Bad data after payment. The defines no refund and x402 has no dispute process, so the client bears the loss.Source [26, 27] Its only remedy in this scenario is a low score.
- Self-review or fake reviews. The contract rejects feedback from the ’s owner or operators with “Self-feedback not allowed”.Source [12] It does not stop reviewers, and the spec leaves that to filtering by trusted reviewers.Source [2] One 2026 study found coordinated Sybil behavior among 90.6% of reviewers on Base.Source [28]
- Fake proof. A
txHashthat pays someone else is not flagged on chain;getSummarystill averages the value.Source [12] - Changed registration. A file served over HTTPS can change with no on-chain event.Source [2, 19]
Costs fall on two parties. The pays settlement gas; the CDP facilitator makes the first 1,000 on-chain transactions each month free and then charges $0.001 each (as of 2026-10-11).Source [21] The client pays the gas for giveFeedback, measured on 2026-10-11 at about 155,185 to 178,504 gas for a first feedback.Source [29] Applications can sponsor that gas with EIP-7702.Source [2]
Variants
- Solana instead of an EVM chain. The client sends a partially signed transaction, and the may be the merchant or a , named in
extra.feePayer.Source [11] - The same call as an tool. An unpaid tool call returns
isErrorwith thePaymentRequiredobject instructuredContent, and the client retries with_metax402/payment.Source [30] The seller’s then lists an MCP service instead of a web one.Source [2]
Flow player: An agent buys one API call: discovery, x402 exact payment, ERC-8004 feedback
A client agent finds a paid weather endpoint through the x402 Bazaar or an ERC-8004 registration, pays for one call with x402 V2 exact (EIP-3009 on an EVM chain, gas paid by the facilitator), then publishes an off-chain feedback file carrying proofOfPayment and calls giveFeedback with its URI and hash.
Spec version: x402 v2.0; ERC-8004 Draft (text of 2026-01-25) (2026-01-25).
Crosses a trust boundary
Use the left and right arrow keys to step, space to play or pause, Home and End to jump.
Step 1 of 14Client agent to Bazaar discovery endpoint
GET /discovery/resources (Bazaar)
Path A. The client asks a facilitator's Bazaar for paid resources, filtered by type, scheme and network. Each listing repeats the accepts entries the server will demand, so the client can see the price before it calls.
Spec: 8.1 GET /discovery/resources for step 1 (external link)
# Illustrative example, spec version x402 v2.0.
GET /discovery/resources?type=http&scheme=exact&network=eip155:8453&limit=20 HTTP/1.1
Host: facilitator.example
# response body
{
"x402Version": 2,
"items": [
{
"resource": "https://api.weather.example/weather",
"type": "http",
"x402Version": 2,
"accepts": [
{ "scheme": "exact", "network": "eip155:8453", "amount": "10000",
"asset": "0x8335...2913", "payTo": "0xB0B0...0B0B", "maxTimeoutSeconds": 60,
"extra": { "name": "USD Coin", "version": "2" } }
],
"lastUpdated": "2026-10-11T09:00:00.000Z"
}
],
"pagination": { "limit": 20, "offset": 0, "total": 1 }
}Control point: Before authorization: allowlist sellers and networks; treat a listing as a claim by the seller, not a check of the seller.
Observable: Public: the Bazaar listing (resource URL, accepts entries, lastUpdated) can be read by anyone; the CDP instance needs no API key.
Step 1 of 14: Client agent to Bazaar discovery endpoint. GET /discovery/resources (Bazaar). Crosses a trust boundary.
Which protocol owns each step
- x402
- ERC-8004: Trustless Agents
| Step | From and to | Protocol | Control point | Observable from outside |
|---|---|---|---|---|
| 1. GET /discovery/resources (Bazaar) (crosses a trust boundary) | Client agent to Bazaar discovery endpoint | x402 | Before authorization: allowlist sellers and networks; treat a listing as a claim by the seller, not a check of the seller. | Public: the Bazaar listing (resource URL, accepts entries, lastUpdated) can be read by anyone; the CDP instance needs no API key. |
| 2. Read tokenURI and getAgentWallet (ERC-8004) (crosses a trust boundary) | Client agent to ERC-8004 Identity Registry | ERC-8004: Trustless Agents | Before authorization: require a minimum reputation from a curated reviewer list; refuse agents whose NFT changed owner since the wallet was bound. | Public: Registered, URIUpdated, MetadataSet and Transfer events; reads are free and leave no trace on chain. |
| 3. Fetch the registration file (crosses a trust boundary) | Client agent to IPFS or HTTPS host | ERC-8004: Trustless Agents | At the edge: match the serving domain against the registration file and https://{endpoint-domain}/.well-known/agent-registration.json. | Public: the registration file at the agentURI and the optional /.well-known domain proof. |
| 4. GET /weather (no payment header) (crosses a trust boundary) | Client agent to Seller resource server | x402 | None | Private |
| 5. 402 Payment Required with PAYMENT-REQUIRED (crosses a trust boundary) | Seller resource server to Client agent | x402 | Before authorization: client policy and SDK spendControls decide whether to pay at all (default: default assets only, at most $1 per payment in the TypeScript SDK). | Private: the 402 and its header travel only between client and server. |
| 6. Check payTo against agentWallet, sign EIP-3009 | Client agent to Client agent | x402 | At signing: a short validBefore window, a wallet signing policy, and a payee check against ERC-8004 agentWallet. | Private |
| 7. Retry with PAYMENT-SIGNATURE (crosses a trust boundary) | Client agent to Seller resource server | x402 | At the edge: payment middleware or a CDN gateway can inspect the request before it reaches the handler. | Private |
| 8. POST /verify, run the handler (crosses a trust boundary) | Seller resource server to x402 facilitator | x402 | None | Private |
| 9. POST /settle (crosses a trust boundary) | Seller resource server to x402 facilitator | x402 | At settlement: facilitator sanctions and KYT screening (the CDP facilitator runs OFAC and Know Your Transaction checks), onBeforeSettle hooks, deduplication across settle workers. | Private |
| 10. transferWithAuthorization (facilitator pays gas) (crosses a trust boundary) | x402 facilitator to Token contract (EVM chain) | x402 | None | Public: an ordinary token Transfer plus AuthorizationUsed event; nothing on chain marks it as an x402 payment. |
| 11. 200 OK with PAYMENT-RESPONSE (crosses a trust boundary) | Seller resource server to Client agent | x402 | None | Private: the response and its header stay between server and client; only the transaction hash points to public chain data. |
| 12. Publish the feedback file with proofOfPayment (crosses a trust boundary) | Client agent to IPFS or HTTPS host | ERC-8004: Trustless Agents | After the fact: the client's own record of what it paid and why it scored the seller as it did. | Public once published: anyone with the feedbackURI can read the file, including the payer address and the transaction hash. |
| 13. giveFeedback(agentId, value, valueDecimals, tag1, tag2, endpoint, feedbackURI, feedbackHash) (crosses a trust boundary) | Client agent to ERC-8004 Reputation Registry | ERC-8004: Trustless Agents | None | Public: NewFeedback event with agentId, clientAddress, feedbackIndex, value, valueDecimals, tags, endpoint, feedbackURI and feedbackHash. |
| 14. Fetch the file, check hash and txHash (crosses a trust boundary) | Indexer or reader to IPFS or HTTPS host | ERC-8004: Trustless Agents | After the fact: score only feedback whose proof resolves to a real transfer to the agent's agentWallet, from reviewers you trust. | Public: subgraphs and explorers index NewFeedback; the file and the transfer are both public, so they can be joined. |
Sequence diagram: An agent buys one API call: discovery, x402 exact payment, ERC-8004 feedback
Scroll to see the whole diagram
Diagram loads when it scrolls into view.
Generated from the flow definition (spec version x402 v2.0; ERC-8004 Draft (text of 2026-01-25), 2026-01-25). The player above uses the same data.
Text alternative
Sequence diagram: An agent buys one API call: discovery, x402 exact payment, ERC-8004 feedback. 9 participants: Client agent, Bazaar discovery endpoint, ERC-8004 Identity Registry, IPFS or HTTPS host, Seller resource server, x402 facilitator, Token contract (EVM chain), ERC-8004 Reputation Registry, and Indexer or reader. 14 steps, 13 crossing a trust boundary, 13 failure branches. Based on several protocols x402 v2.0; ERC-8004 Draft (text of 2026-01-25) (2026-01-25). Step 1: Client agent to Bazaar discovery endpoint: GET /discovery/resources (Bazaar). This step crosses a trust boundary. If The listing is stale and the server now asks for more: The live 402 response wins; the client must compare it with its budget again. Step 2: Client agent to ERC-8004 Identity Registry: Read tokenURI and getAgentWallet (ERC-8004). This step crosses a trust boundary. If The agent NFT was transferred: agentWallet was cleared on transfer; getAgentWallet returns no wallet until the new owner binds one again. Step 3: Client agent to IPFS or HTTPS host: Fetch the registration file. This step crosses a trust boundary. If The file is gone or does not list the endpoint: Nothing on chain flags it; the client should not pay that endpoint. Step 4: Client agent to Seller resource server: GET /weather (no payment header). This step crosses a trust boundary. Step 5: Seller resource server to Client agent: 402 Payment Required with PAYMENT-REQUIRED. This step crosses a trust boundary. Step 6: Client agent to Client agent: Check payTo against agentWallet, sign EIP-3009. If payTo differs from the agent's agentWallet: Neither protocol forces this check; a client that skips it can pay an address the agent never verified. If The amount is above the spend cap: The SDK rejects the entry and no payment is created. Step 7: Client agent to Seller resource server: Retry with PAYMENT-SIGNATURE. This step crosses a trust boundary. If The header is malformed: The server answers 400 (invalid payment). Step 8: Seller resource server to x402 facilitator: POST /verify, run the handler. This step crosses a trust boundary. If isValid is false (for example insufficient_funds or invalid_exact_evm_payload_signature): The server answers 402 again and the handler does not run. If The handler fails: The server does not settle, so the client is not charged. Step 9: Seller resource server to x402 facilitator: POST /settle. This step crosses a trust boundary. If The settle call times out or returns settlement_pending: The outcome is indeterminate; the server must reconcile the broadcast hash before it retries. Step 10: x402 facilitator to Token contract (EVM chain): transferWithAuthorization (facilitator pays gas). This step crosses a trust boundary. If The nonce was used or the balance dropped: The transaction reverts and the facilitator returns success false. Step 11: Seller resource server to Client agent: 200 OK with PAYMENT-RESPONSE. This step crosses a trust boundary. Step 12: Client agent to IPFS or HTTPS host: Publish the feedback file with proofOfPayment. This step crosses a trust boundary. Step 13: Client agent to ERC-8004 Reputation Registry: giveFeedback(agentId, value, valueDecimals, tag1, tag2, endpoint, feedbackURI, feedbackHash). This step crosses a trust boundary. If The caller owns or operates the agent: Reverts with "Self-feedback not allowed". If valueDecimals is above 18: Reverts with "too many decimals". Step 14: Indexer or reader to IPFS or HTTPS host: Fetch the file, check hash and txHash. This step crosses a trust boundary. If The txHash does not exist or pays someone else: Nothing on chain flags it and getSummary still counts the value; only off-chain scoring can discount it.
- Step 1: Client agent to Bazaar discovery endpoint: GET /discovery/resources (Bazaar). This step crosses a trust boundary. If The listing is stale and the server now asks for more: The live 402 response wins; the client must compare it with its budget again.
- Step 2: Client agent to ERC-8004 Identity Registry: Read tokenURI and getAgentWallet (ERC-8004). This step crosses a trust boundary. If The agent NFT was transferred: agentWallet was cleared on transfer; getAgentWallet returns no wallet until the new owner binds one again.
- Step 3: Client agent to IPFS or HTTPS host: Fetch the registration file. This step crosses a trust boundary. If The file is gone or does not list the endpoint: Nothing on chain flags it; the client should not pay that endpoint.
- Step 4: Client agent to Seller resource server: GET /weather (no payment header). This step crosses a trust boundary.
- Step 5: Seller resource server to Client agent: 402 Payment Required with PAYMENT-REQUIRED. This step crosses a trust boundary.
- Step 6: Client agent to Client agent: Check payTo against agentWallet, sign EIP-3009. If payTo differs from the agent's agentWallet: Neither protocol forces this check; a client that skips it can pay an address the agent never verified. If The amount is above the spend cap: The SDK rejects the entry and no payment is created.
- Step 7: Client agent to Seller resource server: Retry with PAYMENT-SIGNATURE. This step crosses a trust boundary. If The header is malformed: The server answers 400 (invalid payment).
- Step 8: Seller resource server to x402 facilitator: POST /verify, run the handler. This step crosses a trust boundary. If isValid is false (for example insufficient_funds or invalid_exact_evm_payload_signature): The server answers 402 again and the handler does not run. If The handler fails: The server does not settle, so the client is not charged.
- Step 9: Seller resource server to x402 facilitator: POST /settle. This step crosses a trust boundary. If The settle call times out or returns settlement_pending: The outcome is indeterminate; the server must reconcile the broadcast hash before it retries.
- Step 10: x402 facilitator to Token contract (EVM chain): transferWithAuthorization (facilitator pays gas). This step crosses a trust boundary. If The nonce was used or the balance dropped: The transaction reverts and the facilitator returns success false.
- Step 11: Seller resource server to Client agent: 200 OK with PAYMENT-RESPONSE. This step crosses a trust boundary.
- Step 12: Client agent to IPFS or HTTPS host: Publish the feedback file with proofOfPayment. This step crosses a trust boundary.
- Step 13: Client agent to ERC-8004 Reputation Registry: giveFeedback(agentId, value, valueDecimals, tag1, tag2, endpoint, feedbackURI, feedbackHash). This step crosses a trust boundary. If The caller owns or operates the agent: Reverts with "Self-feedback not allowed". If valueDecimals is above 18: Reverts with "too many decimals".
- Step 14: Indexer or reader to IPFS or HTTPS host: Fetch the file, check hash and txHash. This step crosses a trust boundary. If The txHash does not exist or pays someone else: Nothing on chain flags it and getSummary still counts the value; only off-chain scoring can discount it.
Source of truth: 8.1 GET /discovery/resources (external link) Generated from src/content/flows/multi-agent-buys-one-api-call.json.
Actors and protocol boundaries
An agent buys one API call: actors and protocol boundaries
Scroll to see the whole diagram
Diagram loads when it scrolls into view.
Discovery runs through the x402 Bazaar or ERC-8004 registries; payment is x402 between client, seller, facilitator and token contract; feedback is ERC-8004, with the proof of payment in an off-chain file and only value, decimals, tags and the revoked flag in registry storage. Numbers follow the scenario flow.
Text alternative
Flowchart. The client agent finds the seller either through an x402 Bazaar discovery listing or by reading the ERC-8004 Identity Registry, whose agentURI points to a registration file with services and x402Support. The client requests the resource from the seller's resource server, gets a 402, and retries with a signed payment. The resource server asks the x402 facilitator to verify and settle; the facilitator pays the gas and calls transferWithAuthorization on the token contract, which emits Transfer and AuthorizationUsed. The client then publishes a feedback file carrying proofOfPayment to off-chain storage and calls giveFeedback on the ERC-8004 Reputation Registry with the file URI and hash; the registry stores value, decimals, tags and the revoked flag. An indexer or later buyer reads the NewFeedback event, fetches the file and confirms the transfer on chain.
Source of truth: ERC-8004 specification (Draft, 2026-01-25) and the x402 V2 specification (external link) Generated from src/content/diagrams/multi-agent-buys-one-api-call-context.mmd.
Sources
- x402 repository (README, specs, SDKs, contracts) (external link)
- ERC-8004: Trustless Agents (specification source, ERCS/erc-8004.md) (external link)
- ERC-8004: Trustless Agents (external link)
- x402 Protocol Specification v2 (external link)
- x402 docs: Facilitator (external link)
- erc-8004-contracts README (external link)
- CDP Bazaar discovery (external link)
- x402 HTTP transport (V2) (external link)
- Scheme: exact on EVM (external link)
- ERC-8004 best practices: Reputation (external link)
- Scheme: exact on Solana (SVM) (external link)
- ReputationRegistryUpgradeable.sol (external link)
- ERC-8004: Trustless Agents (external link)
- Update ERC-8004: Updates from community feedback (external link)
- Commit history of ERCS/erc-8004.md (external link)
- x402Client.ts (SpendControls, DEFAULT_MAX_AMOUNT_PER_PAYMENT) (external link)
- @x402/core CHANGELOG.md (external link)
- x402 docs: SDK features and parity (external link)
- IdentityRegistryUpgradeable.sol (external link)
- Monetization Gateway beta (external link)
- CDP x402 facilitator: pricing and supported networks (external link)
- CDP x402 facilitator docs (pricing, networks, KYT and OFAC) (external link)
- ERC-3009: Transfer With Authorization (external link)
- Agent0 subgraphs live: indexing the ERC-8004 agent economy (external link)
- Scheme: batch-settlement on EVM (external link)
- Scheme: exact (network independent) (external link)
- Scheme: auth-capture (external link)
- Can Trustless Agents Be Trusted? An Empirical Study of the ERC-8004 Decentralized AI Agent Ecosystem (external link)
- Gas estimates for register and giveFeedback via eth_estimateGas on Ethereum and Base (external link)
- x402 MCP transport (V2) (external link)
- Extension: bazaar (external link)