<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ignacio Pastor Sánchez</title>
    <description>The latest articles on DEV Community by Ignacio Pastor Sánchez (@ignacio_pastor).</description>
    <link>https://dev.to/ignacio_pastor</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4278300%2Fd6fb26ac-8b2f-4a01-a895-a3dc0218e0ac.png</url>
      <title>DEV Community: Ignacio Pastor Sánchez</title>
      <link>https://dev.to/ignacio_pastor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ignacio_pastor"/>
    <language>en</language>
    <item>
      <title>Sente: hand your trading strategy to an AI agent that can't break its limits</title>
      <dc:creator>Ignacio Pastor Sánchez</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:37:40 +0000</pubDate>
      <link>https://dev.to/ignacio_pastor/sente-hand-your-trading-strategy-to-an-ai-agent-that-cant-break-its-limits-539g</link>
      <guid>https://dev.to/ignacio_pastor/sente-hand-your-trading-strategy-to-an-ai-agent-that-cant-break-its-limits-539g</guid>
      <description>&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;Sente is a &lt;strong&gt;trading app for Android and the web where you trade &lt;a href="https://www.kuru.io/" rel="noopener noreferrer"&gt;Kuru&lt;/a&gt; spot and &lt;a href="https://perpl.xyz/" rel="noopener noreferrer"&gt;Perpl&lt;/a&gt; perps on Monad yourself, or hire an AI agent to trade them for you.&lt;/strong&gt; The agent follows a strategy you pick or write, runs without you, and can never spend past limits you set. Built for the Monad Metropolis 2026 hackathon, where it ran on Monad testnet; it's offline now. The code can be found &lt;a href="https://github.com/IpastorSan/sente-monad-hackathon" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You trade, or your agent does.&lt;/strong&gt; Kuru's spot order book and Perpl's perps exchange in one app, with one portfolio and one passkey sign-in, and no seed phrase.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The agent works inside a mandate.&lt;/strong&gt; Venues, markets, order size, deposit caps, leverage and an end date, all limits the agent can't raise.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It sleeps until it's needed.&lt;/strong&gt; Watchers check prices, bands, indicators and funding every tick without a model call, and wake the model only when one fires.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You can watch it think.&lt;/strong&gt; A live terminal streams each run, and an append-only ledger keeps every thesis, order, fill and refusal.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Six preset strategies, your own, or someone else's.&lt;/strong&gt; Hire a copy of a published agent and its creator earns 3 bps on the copy's Kuru fills.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The limits hold below the prompt.&lt;/strong&gt; The mandate becomes rules Privy's enclave checks before it signs, owned by a key on your phone. A hijacked prompt can't widen them, and neither can a breached Sente server.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Code:&lt;/strong&gt; &lt;a href="https://github.com/IpastorSan/sente-monad-hackathon" rel="noopener noreferrer"&gt;github.com/IpastorSan/sente-monad-hackathon&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Sente does
&lt;/h2&gt;

&lt;p&gt;Sente is a &lt;strong&gt;trading app&lt;/strong&gt; for Android and desktop web where you trade Kuru spot and Perpl perps on Monad yourself, or hand the trading to an AI agent. &lt;strong&gt;You give the agent a strategy and a mandate, a set of limits it can't raise, and it trades without anyone watching.&lt;/strong&gt; Between runs, watchers outside the chain check the market on every tick and wake the model only when a condition comes true, so you don't pay for model calls that end in "nothing to do". When it wakes, you can watch it reason in a live terminal and read every thesis, order and refusal in its ledger. The strategy can be one of six presets, your own words, or a copy of an agent someone else designed and published. When a copy of your agent trades, you get a cut of Sente's fees.&lt;/p&gt;

&lt;p&gt;One of the main focuses of the build was &lt;strong&gt;how to ensure that funds are safe.&lt;/strong&gt; An agent with your money and no supervisor is only worth hiring if its limits hold when the model misbehaves, when its prompt is hijacked, or even when our own server is breached.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two venues, one app
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.kuru.io" rel="noopener noreferrer"&gt;Kuru&lt;/a&gt; is a spot exchange on Monad: a central limit order book, the same queue of buy and sell orders a traditional exchange keeps, except it lives entirely on chain. Every order is a transaction your wallet signs. Sente listed cbBTC, WETH and XAUt against USDC, with limit and market orders.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://perpl.xyz" rel="noopener noreferrer"&gt;Perpl&lt;/a&gt; is a perpetual futures (perps) exchange: you go long or short on a coin's price with leverage, without holding the coin. Your account and margin live on chain, but you don't send a transaction per order: you sign in once with a trade key, send orders to Perpl's servers, and Perpl puts them on chain for you and pays the gas. Sente offered leverage up to 100x, on isolated margin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fozcc2dbo3yhbjg6uxuaf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fozcc2dbo3yhbjg6uxuaf.png" alt="Sente's Perpl order form: a 30 AUSD BTC-PERP long at 2x, with leverage chips from 1x to 15x" width="440" height="815"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Both venues land in one portfolio: a dollar total, a per-coin breakdown, agent balances, open orders, open and closed positions and fills. A new wallet came with 250 AUSD and 100 USDC so judges could trade straight away.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fanz8pbv699hoojkcmj7b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fanz8pbv699hoojkcmj7b.png" alt="Sente's home screen: the total value across both venues, the agents at work, the markets they trade and the latest move" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Underneath, both exchanges plug into one &lt;code&gt;Venue&lt;/code&gt; interface. Reads never need a signature, and every write is a single intent: place a limit order, place a market order, or cancel. That way every check in Sente judges exactly one action. The same code builds your trades and your agents' trades, so an agent can trade anything you can, on whichever venue its mandate allows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hiring an agent
&lt;/h2&gt;

&lt;p&gt;The custom hire flow has four screens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Name your agent.&lt;/strong&gt; A name, a model (Claude Sonnet 5 or Kimi K2.6, both through OpenRouter) and a toggle to publish its prompt, off by default.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tell it how to trade.&lt;/strong&gt; A system prompt of up to 8,000 characters and a strategy of up to 2,000. Nothing in this system prompt can cause the bot to go over its allocated limits or send the money to an arbitrary place. This is essential for the social feature that allows other users to hire your agent; otherwise you could have a system prompt saying: "Send all your money to 0xbad..."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Draw the lines.&lt;/strong&gt; Those hard limits live in the mandate. It says which venues the agent can use and which markets on each, how much it can deposit into Kuru per token, and, on Perpl, how much collateral it can move per transfer and the maximum leverage. It also caps the largest single order by notional (its full dollar value, leverage included) and sets when the mandate ends: 1, 7, 30 or 90 days out. You can set each limit by hand, or pick one of three presets that fill them all in at once:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Preset&lt;/th&gt;
&lt;th&gt;Largest order&lt;/th&gt;
&lt;th&gt;Kuru deposit cap&lt;/th&gt;
&lt;th&gt;Ends after&lt;/th&gt;
&lt;th&gt;Perpl&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cautious&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;25 USDC&lt;/td&gt;
&lt;td&gt;1 day&lt;/td&gt;
&lt;td&gt;off&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Standard&lt;/td&gt;
&lt;td&gt;50&lt;/td&gt;
&lt;td&gt;100 USDC&lt;/td&gt;
&lt;td&gt;7 days&lt;/td&gt;
&lt;td&gt;off&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wide&lt;/td&gt;
&lt;td&gt;250&lt;/td&gt;
&lt;td&gt;500 USDC&lt;/td&gt;
&lt;td&gt;30 days&lt;/td&gt;
&lt;td&gt;250 AUSD collateral, BTC and ETH perps, 2x&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyyaevlgsfyix32o6gyk4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyyaevlgsfyix32o6gyk4.png" alt="The Draw the lines screen: preset chips, venues and markets, Kuru deposit caps and the largest single order" width="800" height="1088"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Review the mandate.&lt;/strong&gt; Fund it with USDC (and AUSD if Perpl is on), then tick "I understand the agent can lose the funds I give it".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy4m63zyel8n71bjzg0bw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy4m63zyel8n71bjzg0bw.png" alt="The Review the mandate screen: the limits the enclave enforces, listed apart from the ones Sente checks" width="800" height="1016"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each agent gets its own wallet, &lt;strong&gt;a Privy server wallet whose key never leaves Privy's enclave and only signs what the mandate allows&lt;/strong&gt;. It is separate from your own in-app wallet, and it opens its own Kuru and Perpl accounts. The money you fund it with is the most it can ever put at risk, and the mandate caps how much of it goes into any single trade. When you change your mind you amend the mandate or revoke it, and a revoked agent can still send any remaining funds back to you.&lt;/p&gt;

&lt;p&gt;Every hired agent also comes with an MCP endpoint and a token. Point any MCP client at it and it can drive the agent under the same mandate and the same checks as Sente's own runner.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running without you
&lt;/h2&gt;

&lt;p&gt;Once it's funded, the agent runs on its schedule, and every run starts from a snapshot of where it stands: its balances, positions and open orders, plus the five best buy and sell prices on every market the mandate allows.&lt;/p&gt;

&lt;p&gt;With that in hand, the model reads a &lt;strong&gt;system prompt&lt;/strong&gt; built in a fixed order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sente's own rules come first: the mandate can't change, every trade needs a thesis recorded first, a refusal is final, and when there's nothing to do the agent stops.&lt;/li&gt;
&lt;li&gt;The mandate itself, as JSON.&lt;/li&gt;
&lt;li&gt;Your prompt and strategy, bolted in a &lt;code&gt;&amp;lt;user_instructions&amp;gt;&lt;/code&gt; block, so the model can always tell what you wrote apart from Sente's rules, and your text can't pass itself off as one of them.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;The agent has tools, 21 of them:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Twelve read the market and the agent's own state: the mandate, markets, depth, candles, quotes, funding, balances, positions, open orders, watchers, Nansen smart-money signals, and &lt;code&gt;get_indicators&lt;/code&gt;, which computes 13 technical indicators (moving averages, MACD, RSI, stochastic, ATR, Bollinger, VWAP, OBV, ADX and a few more) on up to four timeframes in one call. The model never does arithmetic on raw candles. To check whether a market looks overbought, for example, it asks for the RSI (relative strength index, a 0–100 momentum score) on the 15-minute and 4-hour charts, and gets back two numbers.&lt;/li&gt;
&lt;li&gt;Nine tools act. &lt;code&gt;record_thesis&lt;/code&gt; writes down why it's about to trade. &lt;code&gt;place_limit&lt;/code&gt;, &lt;code&gt;place_market&lt;/code&gt;, &lt;code&gt;deposit&lt;/code&gt;, &lt;code&gt;withdraw&lt;/code&gt;, &lt;code&gt;cancel_order&lt;/code&gt; and &lt;code&gt;close_position&lt;/code&gt; touch the venues. &lt;code&gt;set_watchers&lt;/code&gt; and &lt;code&gt;clear_watchers&lt;/code&gt; decide when it wakes next.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An order tool refuses to run unless a thesis came first, and the tool gate enforces that, no matter what the prompt says. &lt;strong&gt;This is the rule I'd carry to any agent that acts on its own: if a step matters, put it in code the model can't talk past.&lt;/strong&gt; A prompt is a request. A gate is a guardrail. Cancelling, closing and withdrawing never need a thesis, because getting out of a position or getting your money back is a direct instruction from the user.&lt;/p&gt;

&lt;p&gt;Each run is capped at 12 turns and 3 minutes (24 turns and 8 minutes for Kimi, which returns its reasoning and runs slower). A clean Sonnet run deposited, rested a bid and cancelled it in 33 seconds for $0.114 of model time. The user pays for the model, and Sente never sees a bill it has to absorb. Each user gets their own OpenRouter key with a hard spending cap that OpenRouter enforces, and Sente loads it once with 10 USD of free credit. Every agent that user hires, including a copy of someone else's, spends from that key. When less than 10 cents is left, the scheduler stops starting runs, and a run that hits the cap ends with "credits exhausted".&lt;/p&gt;

&lt;p&gt;The plan after the free tier was top-ups in the same tokens you trade with: packs of 10, 20 or 50 USD paid in USDC or AUSD, or an auto top-up when the balance drops below a threshold you pick.&lt;/p&gt;

&lt;h2&gt;
  
  
  Waking the model only when it matters
&lt;/h2&gt;

&lt;p&gt;Most of the time, the right trade is no trade. An agent on a 5-minute schedule runs about 290 times a day, and most of those runs end with the model reading the book and deciding there's nothing to do. That's a model call, a few cents, a transcript nobody reads and &lt;strong&gt;no market action&lt;/strong&gt;, 290 times a day.&lt;/p&gt;

&lt;p&gt;So an agent leaves &lt;strong&gt;watchers&lt;/strong&gt; behind. A watcher is up to four clauses joined by "all" or "any", and an agent can keep eight. A clause can watch a price (above, below, crossing), a band (inside, outside, entering, leaving), an indicator against a number or against another indicator (MACD crossing its signal on the 15-minute), a Perpl position's P&amp;amp;L as a share of margin, or the funding rate. The agent sets them with &lt;code&gt;set_watchers&lt;/code&gt; at the end of a run: "wake me if cbBTC leaves this band or RSI drops under 30". You can add and edit them yourself from the agent's page too.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;scheduler&lt;/strong&gt; checks every watcher on each tick from cached prices and candles, with no model call. A run starts only when one fires, and the model is told what woke it. A heartbeat (every 4 hours by default) wakes the agent anyway to re-plan, and a cooldown (an hour by default) keeps a choppy market from waking it every tick. Crosses fire once, on the edge. Data that can't be read counts as unknown, never as false, so a dead feed doesn't look like a quiet market.&lt;/p&gt;

&lt;p&gt;Checking every watcher on every tick sounds like a lot of work, but it's cheap. An agent has at most eight watchers of four clauses each, so a check is a few dozen comparisons. The data behind them is shared: prices come from one cached ticker and candles from one shared cache, and a check reads each market once however many clauses use it. A hundred agents watching cbBTC read the same numbers, so &lt;strong&gt;the data cost grows with the number of markets, not the number of agents.&lt;/strong&gt; Computing an RSI over 200 candles takes milliseconds.&lt;/p&gt;

&lt;p&gt;What would hurt us first at real scale is the per-agent work: indicators recomputed by every agent that asks for the same one, Perpl positions read account by account, and a single scheduler loop polling every agent every 15 seconds. The fix would be to flip the trigger. Today each agent's timer asks "has anything I care about changed?". Instead, a new price for cbBTC would trigger a check only on the watchers on cbBTC. A quiet market would then cost nothing.&lt;/p&gt;

&lt;p&gt;The principle travels well beyond trading. &lt;strong&gt;An LLM is the most expensive and slowest part of an agent&lt;/strong&gt;, so spend it on judgment and nothing else. By contrast, &lt;strong&gt;checking whether a number crossed a line is just arithmetic&lt;/strong&gt;. Let the model decide what to watch for and let plain code do the watching.&lt;/p&gt;

&lt;h2&gt;
  
  
  Watching it think
&lt;/h2&gt;

&lt;p&gt;Press "Run now", optionally with an extra prompt line for this run only ("Ask Night desk to…"), and &lt;strong&gt;the run streams into a live terminal&lt;/strong&gt;: the model's text, its reasoning, every tool call and its result, tokens and cost per turn. Sente keeps the last ten transcripts per agent, so the runs that happened while you slept are there in the morning.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flb9fjq47ruyzrv72mv03.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flb9fjq47ruyzrv72mv03.png" alt="A run streaming into the agent's live terminal: the model reasons about RSI and moving averages, decides to stay flat and sets watchers" width="800" height="1080"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Everything an agent produces goes to one append-only ledger: theses, orders, fills, closes, deposits, verdicts and refusals.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A verdict closes a thesis with its realised P&amp;amp;L.&lt;/li&gt;
&lt;li&gt;A refusal names who refused: &lt;code&gt;sente&lt;/code&gt; for Sente's own pre-check or &lt;code&gt;enclave&lt;/code&gt; for Privy's, so "deposit 2 USDC: refused by the Privy enclave" is a line you can read on the agent's page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The agent's page builds its stats from that ledger: win rate, average hold, best trades and a proof section showing what the agent made you, which orders were held back for breaking its limits, and its largest order.&lt;/p&gt;

&lt;p&gt;Every number on the portfolio is computed from that ledger, not from the wallet's balance, and the two can disagree. Anyone can send tokens to an agent's address, and the wallet also holds the MON it pays gas with. None of that came from a trade, so there's no price it was bought at and no honest profit or loss to show for it. So the portfolio counts only what the ledger can explain. Kuru profit is matched first in, first out: each sale is paired with the oldest buy still open, in exact decimal math rather than JavaScript's floating-point numbers, which round. When a sale has no recorded buy behind it, that amount is left out of the P&amp;amp;L, with a note saying so. A P&amp;amp;L figure is worse than none if it's quietly wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  Six strategies, or your own
&lt;/h2&gt;

&lt;p&gt;Most people won't write an 8,000-character trading prompt. So Sente ships six strategies, each a versioned piece of code with typed parameters. Its &lt;code&gt;render()&lt;/code&gt; writes the strategy and system prompt from those parameters, and suggests a mandate and a schedule to go with them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Guardian&lt;/strong&gt; is a stop-loss and take-profit for a Kuru spot position. You hand it the coins and set two price lines, prefilled 10% either side of the live price; every 1 or 5 minutes it checks the price and sells if either line is crossed. It never buys.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Range Trader&lt;/strong&gt; buys near the bottom of a 1-day, 3-day or 1-week range and sells near the top, with a target and a stop as percentages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trend Rider&lt;/strong&gt; trades Perpl breakouts over a 12-hour to 3-day lookback, long only or both ways, 1x to 5x, with a trailing stop.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Funding Harvester&lt;/strong&gt; shorts a perp while funding pays shorts above a threshold you pick, optionally hedges on Kuru, and closes when funding flips.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DCA Stacker&lt;/strong&gt; buys a fixed amount daily or weekly on Kuru, can buy double after a 5% drop, and stops at a budget cap.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mean Reverter&lt;/strong&gt; bets that a sharp move will snap back. When price stretches 2% to 6% away from its recent average, it trades against the move (it buys after a drop, or on Perpl shorts after a spike), takes profit once price has recovered part of the way, and exits at a stop if the move keeps going.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hiring a preset agent is three steps: its parameters, a mandate prefilled from its suggestion, and a review of name, model, schedule and funding.&lt;/p&gt;

&lt;p&gt;The Guardian preset is a special case as it also answers a gap in the venues. Neither Kuru nor Perpl has stop orders on testnet, and Sente can't place one for you either, because only your device holds your trading keys. So where a trading app would put its stop-loss fields, Sente's Kuru order form says they aren't offered and points you to "Protect it with a Guardian agent" instead.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frmrspa0c0vnpkfma934w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frmrspa0c0vnpkfma934w.png" alt="An open BTC-PERP position on Perpl. Where the stop-loss would go, Sente says it isn't on Perpl yet and points to an agent" width="520" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If none of the six fits, the custom flow takes your own prompt and strategy. And if someone else already wrote the one you want, you can hire theirs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hire a copy
&lt;/h2&gt;

&lt;p&gt;Every agent has a public page at &lt;code&gt;/a/&amp;lt;id&amp;gt;&lt;/code&gt; that anyone can read, signed in or not: its mandate, its own trades, the orders its limits refused, and what its wallet holds. It's the agent's record, not yours: your own trades, your wallet address and your account stay private, and you appear only under the name you chose. The agent's wallet trades on chain, so its history is public anyway. Publishing the agent adds its system prompt and strategy to the page. A signed-in visitor sees one more button: "Hire a copy".&lt;/p&gt;

&lt;p&gt;A copy takes the model, the system prompt, the strategy and the preset parameters. The hirer writes their own mandate, which compiles into a new policy on a new wallet, funds it themselves and pays for its runs with their own credits. With Sente you can borrow somebody's idea, and it won't cost you any extra fee.&lt;/p&gt;

&lt;p&gt;Creators get paid. Sente takes a 0.1% builder fee on Kuru, and when a copy's order fills, 3 of those 10 basis points belong to the agent it was copied from. The fee is recorded per creator, and then paid out periodically from the treasury.&lt;/p&gt;

&lt;p&gt;To find an agent worth copying, the Agents tab has a Top board that ranks agents by realised ROI, then win rate. Kuru numbers come from an &lt;a href="https://envio.dev/" rel="noopener noreferrer"&gt;Envio&lt;/a&gt; index of on-chain fills, so a creator can't inflate them. Agents with fewer than three trades sit apart under "Too few trades to rank". Perpl results don't come from Envio, but from the agents' own ledgers, labelled and unranked, because Perpl's order event fires about 211,000 times an hour and Envio's development plan stops at 100,000 events.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the limits hold
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7r0yq1phpxipuscbsmi5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7r0yq1phpxipuscbsmi5.png" alt="An agent's page: what the enclave enforces, what Sente enforces, and an order Sente held back for exceeding the mandate's cap" width="800" height="697"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every promise above depends on an agent being unable to reason its way past its mandate. A prompt can't ensure this kind of guardrail, so that falls on the wallets instead. I wrote about Privy policies and key quorums in the &lt;a href="https://ignaciopastorsanchez.com/blog/privy-spending-mandates-key-quorums" rel="noopener noreferrer"&gt;Turnstile spending-mandates post&lt;/a&gt;. Sente uses the same tools and adds four things.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One passkey, two keys, no seed phrase.&lt;/strong&gt; A passkey is the fingerprint or face login your phone already uses, and its PRF extension can turn it into secrets: 32 bytes that depend on the passkey, the site and a salt. Sente asks for two, with two salts, because it needs keys on two different curves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One becomes an Ethereum key, which is how you sign in: Sente's server knows you as that address.&lt;/li&gt;
&lt;li&gt;The other becomes a P-256 key, the kind Privy accepts as an owner. It owns your Privy wallet, where your money sits, and every agent's mandate, and it never leaves your device.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Neither key is ever written down, so there's no seed phrase to lose: the same passkey re-derives both at every sign-in, and Sente's server can't sign for your wallet because it never holds either one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The mandate becomes enclave rules.&lt;/strong&gt; Sente compiles the same mandate object you reviewed into a Privy policy: allowed contracts, tokens, amounts, chain and expiry, all fields the enclave can check before it signs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The agent's key is just a signer, never an owner.&lt;/strong&gt; A Privy owner can detach a policy from a wallet. A signer can't. So the agent's key is a signer bound to the mandate policy. When you amend a mandate, your phone compiles the new rules itself and signs only if they match the server's exactly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your phone rebuilds your trades.&lt;/strong&gt; Your personal wallet (the "human" one) has no agent and no policy, only your device key as owner. Sente's server plans each trade (approve, deposit, place) and your phone decodes every step against what you confirmed and the order book it read itself, signing nothing unless all of it matches.&lt;/p&gt;

&lt;p&gt;Revoking an agent (cancelling its mandate, turning the agent off) doesn't cause the money to be lost as dust in random wallets. The compiler always emits two recovery rules with no expiry, a withdrawal and a transfer, and both can only send funds to your registered wallet. A revoke replaces the mandate with exactly those.&lt;/p&gt;

&lt;p&gt;It's the same idea as the rule that an order needs a thesis first: don't leave a limit to the part that might break it. So every order is checked twice. Sente checks it against the mandate first, which is what lets it say in plain words why an order was refused. Then Privy's enclave checks it again before signing, because Sente's own check could have a bug, be switched off or be hacked. A model can be talked into things and a server can be hacked, but the enclave signs only what the policy allows, whoever is asking. That's why the limits that really matter live there, out of reach of anything that could be talked or forced into raising them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/sente-monad-hackathon" rel="noopener noreferrer"&gt;Sente repository&lt;/a&gt;: the app, the API and the mandate packages; the README has the architecture and the evidence for each claim.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/sente-monad-hackathon/blob/main/docs/judges.md" rel="noopener noreferrer"&gt;Judge walkthrough&lt;/a&gt;: every screen, the hire flow and the mandate presets, step by step.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/sente-monad-hackathon/blob/main/docs/agents.md" rel="noopener noreferrer"&gt;Agents&lt;/a&gt;: the runner, the tools, indicators, watchers, the scheduler and the creator fee.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/sente-monad-hackathon/blob/main/docs/privy-policy-enforcement.md" rel="noopener noreferrer"&gt;Privy policy enforcement&lt;/a&gt;: how a mandate compiles to enclave rules, and the escalation probe.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/sente-monad-hackathon/blob/main/docs/user-wallet.md" rel="noopener noreferrer"&gt;User wallet&lt;/a&gt; and &lt;a href="https://github.com/IpastorSan/sente-monad-hackathon/blob/main/docs/user-trading.md" rel="noopener noreferrer"&gt;user trading&lt;/a&gt;: the passkey-derived keys and the phone-verified trade flow.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/sente-monad-hackathon/blob/main/docs/kuru.md" rel="noopener noreferrer"&gt;Kuru&lt;/a&gt; and &lt;a href="https://github.com/IpastorSan/sente-monad-hackathon/blob/main/docs/perpl.md" rel="noopener noreferrer"&gt;Perpl&lt;/a&gt;: the venue adapters, testnet deployments and their limits.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/sente-monad-hackathon/blob/main/docs/erc8004.md" rel="noopener noreferrer"&gt;ERC-8004 anchor&lt;/a&gt; and &lt;a href="https://github.com/IpastorSan/sente-monad-hackathon/blob/main/docs/leaderboard.md" rel="noopener noreferrer"&gt;leaderboard&lt;/a&gt;: the on-chain mandate hash and the Envio-indexed Top board.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/sente-monad-hackathon/blob/main/docs/demo-refusal.md" rel="noopener noreferrer"&gt;The refusal demo&lt;/a&gt;: the run where the enclave refused a 2 USDC deposit and the model's own account of it.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://testnet.monadscan.com/tx/0x322199e0f656f13f243081a96ea366a281a98a84e13a3965ff04799499affb95" rel="noopener noreferrer"&gt;Monadscan: agent #2207's mandate anchor&lt;/a&gt;: the hash written and read back active.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.privy.io/controls/policies/overview.md" rel="noopener noreferrer"&gt;Privy: Policies overview&lt;/a&gt;: deny-by-default rules evaluated in the enclave before signing.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.privy.io/controls/authorization-keys/owners/types.md" rel="noopener noreferrer"&gt;Privy: Types of owners and signers&lt;/a&gt;: owners, signers and P-256 keys.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://eips.ethereum.org/EIPS/eip-8004" rel="noopener noreferrer"&gt;ERC-8004: Trustless Agents&lt;/a&gt;: the identity registry the mandate hash lives on.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://w3c.github.io/webauthn/#prf-extension" rel="noopener noreferrer"&gt;WebAuthn PRF extension&lt;/a&gt;: the passkey output both keys are derived from.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/category-labs/mera" rel="noopener noreferrer"&gt;mera&lt;/a&gt;: Category Labs' passkey library for Monad.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.kuru.io/" rel="noopener noreferrer"&gt;Kuru&lt;/a&gt;, &lt;a href="https://perpl.xyz/" rel="noopener noreferrer"&gt;Perpl&lt;/a&gt;, &lt;a href="https://envio.dev/" rel="noopener noreferrer"&gt;Envio&lt;/a&gt; and &lt;a href="https://openrouter.ai/" rel="noopener noreferrer"&gt;OpenRouter&lt;/a&gt;: the venues, the indexer and the model gateway.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>blockchain</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Turnstile: a market where AI agents pay per query</title>
      <dc:creator>Ignacio Pastor Sánchez</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:37:31 +0000</pubDate>
      <link>https://dev.to/ignacio_pastor/turnstile-a-market-where-ai-agents-pay-per-query-5g1e</link>
      <guid>https://dev.to/ignacio_pastor/turnstile-a-market-where-ai-agents-pay-per-query-5g1e</guid>
      <description>&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;Turnstile is a market where a seller publishes a priced service at an ENS name, and a buyer's agent discovers it, reads the price from the chain, gets &lt;code&gt;402 Payment Required&lt;/code&gt;, pays per query in HBAR on Hedera or USDC on Arc, and gets an answer, inside a spending limit the agent itself can never raise. &lt;/p&gt;

&lt;p&gt;Built solo in September 2026 for ETHOnline 2026 hackathon and won two prizes: Hedera's AI and agentic payments prize ($2,000) and second place in The Graph's best AI tooling category ($1,500).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Demo video:&lt;/strong&gt; &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/docs/demo/turnstile-demo.mp4" rel="noopener noreferrer"&gt;turnstile-demo.mp4&lt;/a&gt;. The hosted version ran on testnets until November 2026.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code:&lt;/strong&gt; &lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;github.com/IpastorSan/turnstile&lt;/a&gt; (MIT)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This post is the overview. The nine deep dives, in reading order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://ignaciopastorsanchez.com/blog/x402-on-hedera-blocky402-paid-http" rel="noopener noreferrer"&gt;x402 on Hedera: what a paid HTTP request is made of&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ignaciopastorsanchez.com/blog/gasless-nanopayments-eip3009-circle-gateway-arc" rel="noopener noreferrer"&gt;Gasless nanopayments on Arc, and the nonce that stays at 0&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ignaciopastorsanchez.com/blog/chain-agnostic-x402-seller-payment-rails" rel="noopener noreferrer"&gt;One payment interface, four chains&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ignaciopastorsanchez.com/blog/erc8004-agent-discovery-substreams" rel="noopener noreferrer"&gt;A sample of 197 ERC-8004 agents, and where their prices live&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ignaciopastorsanchez.com/blog/ensv2-agent-offer-records-hot-cold-keys" rel="noopener noreferrer"&gt;The offer is the name: ENSv2 records and a key split the chain enforces&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ignaciopastorsanchez.com/blog/world-id-selfie-check-abuse-control" rel="noopener noreferrer"&gt;Three listings per human: capping an open agent registry with World ID Selfie Check&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ignaciopastorsanchez.com/blog/privy-spending-mandates-key-quorums" rel="noopener noreferrer"&gt;Spending mandates for agents: the key that spends can never raise its own limit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ignaciopastorsanchez.com/blog/chainlink-cre-confidential-workflows-sell-the-answer" rel="noopener noreferrer"&gt;Sell the answer, keep the method: Chainlink CRE Confidential Workflows&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ignaciopastorsanchez.com/blog/the-graph-uniswap-paid-liquidity-analyst" rel="noopener noreferrer"&gt;Selling a liquidity verdict: The Graph, Uniswap QuoterV2, and the gap between TVL and depth&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The problem: no standard price
&lt;/h2&gt;

&lt;p&gt;AI agents now have a standard way to register themselves on chain, &lt;a href="https://eips.ethereum.org/EIPS/eip-8004" rel="noopener noreferrer"&gt;ERC-8004&lt;/a&gt;. I read a sample of 197 registrations from short block windows on Base, Ethereum mainnet and Sepolia (Base alone has about 85,000) and asked one question of each: can a buyer's program learn what this agent costs before it pays?&lt;/p&gt;

&lt;p&gt;Two could, and neither through the standard, because the registration format has no price field. Mine publishes its price in an ENS record. One other agent, Capminal, quotes a price in the 402 its endpoint returns. 76 Virtuals agents list a number in the &lt;code&gt;jobOfferings&lt;/code&gt; field of ACP, Virtuals' Agent Commerce Protocol, with no currency attached. Most of the rest set an &lt;code&gt;x402Support&lt;/code&gt; flag, which says they take payment, with no working endpoint to ask. So agents can find each other, but they cannot buy anything from each other in a way a program can reason about.&lt;/p&gt;

&lt;p&gt;Two more gaps sit behind that one. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A seller whose value is its analysis has to choose between publishing the method and asking buyers to take the answer on trust. &lt;/li&gt;
&lt;li&gt;The usual way to let an agent pay is a private key in its environment, which can spend whatever sits behind it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwlrbyuox5c5bxa8te112.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwlrbyuox5c5bxa8te112.png" alt="The Turnstile market page listing 197 real ERC-8004 registrations, with one price posted on chain, 97 agents marked askable and 99 with no price" width="800" height="500"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The market page counts only the prices it can read. It misses the Capminal quote and the Virtuals prices; &lt;a href="https://ignaciopastorsanchez.com/blog/erc8004-agent-discovery-substreams" rel="noopener noreferrer"&gt;Part 4&lt;/a&gt; explains why.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;Turnstile is a market where a seller publishes a priced service at an ENS name, and the resolver record is the offer: price, payment rails and endpoint, read live on-chain on every request. A buyer's agent finds the seller, reads the price, gets a &lt;code&gt;402 Payment Required&lt;/code&gt;, pays per query in HBAR on Hedera or USDC on Arc, and gets an answer. &lt;/p&gt;

&lt;p&gt;To prove the whole loop, the market needed one seller worth paying. For Turnstile, it is the Liquidity Analyst at liquidity.turnstile.eth, and it answers one question about a Uniswap pool: is it safe to LP? It reads the pool's history from a Messari-standard subgraph on The Graph and quotes live trades against Uniswap's QuoterV2. It then returns ACCEPTABLE, CAUTION or AVOID, with a confidence score and the numbers behind each signal. Ranked by TVL, the top pool on our own subgraph was a fake USDT holding two trillion of itself and none of the real one, and it couldn't fill a $1,000 trade. That gap between what an index reports and what a trade can actually do is what the seller charges seven cents to find.&lt;/p&gt;

&lt;p&gt;The buyer's organisation gives that agent a spending mandate, and the agent can never raise its own limit. Built it solo in September 2026 for ETHOnline 2026.&lt;/p&gt;
&lt;h2&gt;
  
  
  Architecture: discover, price, pay, answer
&lt;/h2&gt;

&lt;p&gt;The request path has six steps.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
  A["01 Discover&amp;lt;br/&amp;gt;ERC-8004 · Substreams"] --&amp;gt; B["02 Read the offer&amp;lt;br/&amp;gt;ENSv2 resolver · turnstile:price"]
  B --&amp;gt; C["03 Ask&amp;lt;br/&amp;gt;MCP"]
  C --&amp;gt; D["04 402&amp;lt;br/&amp;gt;quote"]
  D --&amp;gt; E["05 Pay&amp;lt;br/&amp;gt;x402 on Hedera · USDC on Arc"]
  E --&amp;gt; F["06 Answer&amp;lt;br/&amp;gt;the result, not the method"]&lt;/code&gt;&lt;/pre&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Discover.&lt;/strong&gt; A Rust Substreams module normalises ERC-8004 agent registrations. The market and an MCP tool query the same discovery engine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read the offer.&lt;/strong&gt; The seller's ENSv2 subname, &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt; on Sepolia, carries its price and endpoint in standard ENSIP-25/26 records. Nothing is cached or hard-coded.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ask.&lt;/strong&gt; A buyer's agent calls the seller through &lt;code&gt;mcp-turnstile&lt;/code&gt;, a four-tool MCP server with a &lt;code&gt;SKILL.md&lt;/code&gt;. It has no code path for any particular seller.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;402.&lt;/strong&gt; The paid service refuses unpaid requests with a quote.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pay.&lt;/strong&gt; A &lt;code&gt;PaymentRail&lt;/code&gt; seam with two implementations: x402 on Hedera settled through Blocky402, and Circle Gateway nanopayments in USDC on Arc. The same query settles identically over either.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Answer.&lt;/strong&gt; The seller's Liquidity Analyst answers one question, "is this pool safe to LP?", and returns the verdict, not the calibration behind it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1keil3ez2uh6vij9hccz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1keil3ez2uh6vij9hccz.png" alt="Turnstile architecture: the three key tiers, and the request path" width="800" height="653"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The three key tiers
&lt;/h3&gt;

&lt;p&gt;The design rests on one invariant: &lt;strong&gt;the key that spends can never raise its own limit.&lt;/strong&gt; Authority is split across three tiers.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tier&lt;/th&gt;
&lt;th&gt;Holds&lt;/th&gt;
&lt;th&gt;May authorise&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Cold&lt;/strong&gt; (a separate operator key)&lt;/td&gt;
&lt;td&gt;The seller's identity; owns the ENS name&lt;/td&gt;
&lt;td&gt;Rotating the hot key, changing the payout address, raising the price ceiling&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Warm&lt;/strong&gt; (Privy)&lt;/td&gt;
&lt;td&gt;The buyer organisation's wallet and mandate policy&lt;/td&gt;
&lt;td&gt;Funding the agent (&lt;code&gt;depositFor&lt;/code&gt;, to that agent only, up to a cap, paying the gas), issuing a mandate, raising a cap (needs a quorum), adding an agent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Hot&lt;/strong&gt; (Circle, Arc)&lt;/td&gt;
&lt;td&gt;The buyer agent's spending wallet&lt;/td&gt;
&lt;td&gt;Nothing. It spends inside the mandate and signs offchain only&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each tier is enforced where it lives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On Sepolia, the resolver behind the seller's ENS name grants roles per record. The seller's own hot key, which updates its offer, may write only the price and endpoint records, so its &lt;code&gt;setAddr&lt;/code&gt; call to change the payout address reverts with &lt;code&gt;EACUnauthorizedAccountRoles&lt;/code&gt;. A Forge test forked from live Sepolia covers that revert. &lt;/li&gt;
&lt;li&gt;In Privy, a 1-of-2 operations quorum owns the org wallet and a separate 2-of-2 board quorum owns the mandate policy, so raising a cap needs both board signatures and one alone gets a &lt;code&gt;401&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;On Arc, the spending agent only signs EIP-3009 authorisations and Circle Gateway submits them, so after eleven payments the agent's nonce is still 0.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key decisions and tradeoffs
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. The offer lives in the ENS record, not in the API.&lt;/strong&gt; Price, rails and endpoint are standard ENSIP keys on the seller's name, read from Sepolia on every page load. Anyone can read an offer without trusting Turnstile, and the market cannot serve a stale price. The cost is a live RPC dependency: without &lt;code&gt;SEPOLIA_RPC_URL&lt;/code&gt; the seller page shows nothing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Split authority by role, and leave custody for later.&lt;/strong&gt; The three tiers are separate: the chain and Privy decide which key can do what, so the hot key can't move money it doesn't control. Custody is the next step. The cold key is still an ordinary software key, not stored in a hardware wallet, so the split protects against a leaked hot key but not against a compromised operator machine. Making it cold in practice means generating it offline and signing on an air-gapped device. I planned that around Ledger's key ring, which my only device turned out not to support.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Rail-agnostic&lt;/strong&gt; Settlement sits behind one &lt;code&gt;PaymentRail&lt;/code&gt; interface. That keeps adding extra rails cheap and made "the same query settles on both rails" easy to implement. The rails still behave differently, because Hedera and Circle implement 402 payments differently: on Hedera, a facilitator settles each payment as it arrives, while Circle collects payments and settles them in batches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Sell the answer, keep the method.&lt;/strong&gt; The analyst's scoring runs in a &lt;a href="https://chain.link/chainlink-runtime-environment" rel="noopener noreferrer"&gt;Chainlink CRE&lt;/a&gt; confidential workflow. It is designed to run inside an enclave, with the seller's calibration held as a secret. What reaches chain is the rating, the confidence, which checks failed, and a hash of the evidence bundle. A buyer can check that the verdict commits to the exact bytes they paid for, without being able to reproduce it. &lt;br&gt;
The workflow runs in Chainlink's simulator, but deploying it to the oracle network needs two approvals Chainlink hadn't granted by the deadline: deploy access, and the Confidential Workflows private beta. So the verdict on Sepolia was written by my key, from the same scoring run outside the enclave. It shows the buyer's check works, but nothing has been attested yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  What shipped, with receipts
&lt;/h2&gt;

&lt;p&gt;Every item here links to a transaction, a document or a test. The project's &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/docs/EVIDENCE.md" rel="noopener noreferrer"&gt;&lt;code&gt;EVIDENCE.md&lt;/code&gt;&lt;/a&gt; has one row per claim.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hosted product:&lt;/strong&gt; ran on testnets from September to November 2026. The paid endpoint answered &lt;code&gt;402 Payment Required&lt;/code&gt; unpaid, and the MCP URL the ENS record publishes served the tools over HTTP/SSE. The &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/docs/demo/turnstile-demo.mp4" rel="noopener noreferrer"&gt;demo video&lt;/a&gt; shows it running.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Paid request on Hedera&lt;/strong&gt; through Blocky402: 0.84 HBAR ($0.07), buyer gas zero (&lt;a href="https://hashscan.io/testnet/transaction/0.0.7162784@1788791855.758948636" rel="noopener noreferrer"&gt;HashScan&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The same query over both rails&lt;/strong&gt; in one run, same verdict (&lt;a href="https://hashscan.io/testnet/transaction/0.0.7162784@1788800327.098234984" rel="noopener noreferrer"&gt;HashScan&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nanopayments batched on Arc:&lt;/strong&gt; six $0.0005 queries and one $0.07 query settled in one transaction (&lt;a href="https://testnet.arcscan.app/tx/0xd6e77a59ad4740e5f89c9c601a05e7cf7859c9253fb1b3c31a8eae97e859a0c1" rel="noopener noreferrer"&gt;ArcScan&lt;/a&gt;), then a second batch (&lt;a href="https://testnet.arcscan.app/tx/0xe50b8be63a2fe102c70de3b62a43251fbfcac1d8ca93f9f1760dd3c7a7985c39" rel="noopener noreferrer"&gt;ArcScan&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero-gas spending agent:&lt;/strong&gt; nonce 0 after eleven payments (&lt;a href="https://testnet.arcscan.app/address/0x0633a193017939Bb1eB242982397224c66948e2F" rel="noopener noreferrer"&gt;ArcScan&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hot key cannot move the payout:&lt;/strong&gt; reverts on live Sepolia, pinned by a fork test.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mandate approval that refuses:&lt;/strong&gt; a cap raise fails with one Privy signature and passes with two. It is on camera in the demo video.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A World-verified seller:&lt;/strong&gt; I ran World's Selfie Check for our seller from the World Sandbox App, through the site's &lt;code&gt;/onboard&lt;/code&gt; page. The server verifies the proof with World's Developer Portal, keeps only the nullifier (a per-app pseudonym for the human), and stores it under the listing's ERC-8004 agent id, which is what the market reads. The market now lists our seller as verified. One human, one proof so far; the three-listing cap is covered by tests, not by more real proofs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One mainnet payment:&lt;/strong&gt; $0.07 in USDC on Base through the Bazantic gateway, paid from my own wallet to test the listing end to end (&lt;a href="https://basescan.org/tx/0xf1088b77d72de2daea61f6c6f48d1da508c227e8f556b09355b38dd3d2c3919f" rel="noopener noreferrer"&gt;BaseScan&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Graph:&lt;/strong&gt; a Messari DEX AMM-conformant subgraph live on Studio, and an authored Substreams module for ERC-8004 registrations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bonus: A defect reported upstream:&lt;/strong&gt; Uniswap's agent-tooling repo told agents to use an ethers v5 call that no longer exists. I filed &lt;a href="https://github.com/Uniswap/uniswap-ai/issues/148" rel="noopener noreferrer"&gt;the issue&lt;/a&gt;; a maintainer wrote and merged &lt;a href="https://github.com/Uniswap/uniswap-ai/pull/149" rel="noopener noreferrer"&gt;the fix&lt;/a&gt; the same day.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sources and evidence
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Repository: &lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;https://github.com/IpastorSan/turnstile&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Demo video: &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/docs/demo/turnstile-demo.mp4" rel="noopener noreferrer"&gt;https://github.com/IpastorSan/turnstile/blob/main/docs/demo/turnstile-demo.mp4&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Bazantic mainnet payment: &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/docs/bazantic-gateway.md" rel="noopener noreferrer"&gt;https://github.com/IpastorSan/turnstile/blob/main/docs/bazantic-gateway.md&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Hedera settlement: &lt;a href="https://hashscan.io/testnet/transaction/0.0.7162784@1788791855.758948636" rel="noopener noreferrer"&gt;https://hashscan.io/testnet/transaction/0.0.7162784@1788791855.758948636&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Both rails, one query: &lt;a href="https://hashscan.io/testnet/transaction/0.0.7162784@1788800327.098234984" rel="noopener noreferrer"&gt;https://hashscan.io/testnet/transaction/0.0.7162784@1788800327.098234984&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Arc batches: &lt;a href="https://testnet.arcscan.app/tx/0xd6e77a59ad4740e5f89c9c601a05e7cf7859c9253fb1b3c31a8eae97e859a0c1" rel="noopener noreferrer"&gt;https://testnet.arcscan.app/tx/0xd6e77a59ad4740e5f89c9c601a05e7cf7859c9253fb1b3c31a8eae97e859a0c1&lt;/a&gt; , &lt;a href="https://testnet.arcscan.app/tx/0xe50b8be63a2fe102c70de3b62a43251fbfcac1d8ca93f9f1760dd3c7a7985c39" rel="noopener noreferrer"&gt;https://testnet.arcscan.app/tx/0xe50b8be63a2fe102c70de3b62a43251fbfcac1d8ca93f9f1760dd3c7a7985c39&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Agent nonce: &lt;a href="https://testnet.arcscan.app/address/0x0633a193017939Bb1eB242982397224c66948e2F" rel="noopener noreferrer"&gt;https://testnet.arcscan.app/address/0x0633a193017939Bb1eB242982397224c66948e2F&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Base mainnet payment: &lt;a href="https://basescan.org/tx/0xf1088b77d72de2daea61f6c6f48d1da508c227e8f556b09355b38dd3d2c3919f" rel="noopener noreferrer"&gt;https://basescan.org/tx/0xf1088b77d72de2daea61f6c6f48d1da508c227e8f556b09355b38dd3d2c3919f&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Uniswap issue and fix: &lt;a href="https://github.com/Uniswap/uniswap-ai/issues/148" rel="noopener noreferrer"&gt;https://github.com/Uniswap/uniswap-ai/issues/148&lt;/a&gt; , &lt;a href="https://github.com/Uniswap/uniswap-ai/pull/149" rel="noopener noreferrer"&gt;https://github.com/Uniswap/uniswap-ai/pull/149&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>web3</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>TVL is not depth: what a Uniswap pool can actually trade</title>
      <dc:creator>Ignacio Pastor Sánchez</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:37:22 +0000</pubDate>
      <link>https://dev.to/ignacio_pastor/tvl-is-not-depth-what-a-uniswap-pool-can-actually-trade-30gg</link>
      <guid>https://dev.to/ignacio_pastor/tvl-is-not-depth-what-a-uniswap-pool-can-actually-trade-30gg</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 9 of 9 in the &lt;a href="https://ignaciopastorsanchez.com/blog/series/turnstile" rel="noopener noreferrer"&gt;Turnstile series&lt;/a&gt;: building a paid lane for onchain data agents.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Turnstile&lt;/a&gt; sells AI agents one answer per payment: is this Uniswap pool a sensible place to provide liquidity?&lt;/p&gt;

&lt;p&gt;The obvious shortcut is TVL, the total value locked in the pool. But TVL only counts what the pool holds. What matters is &lt;strong&gt;depth&lt;/strong&gt;: how big a trade the pool can fill before the price moves too much. A deep pool attracts trades, and trades are what pay the fees an LP earns. TVL and depth are not the same number, and they can be far apart.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TVL can be fake.&lt;/strong&gt; The three largest pools by TVL on our subgraph were worthless, one of them claiming $1.9 trillion.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TVL can be real and idle.&lt;/strong&gt; In Uniswap v3, most capital sits outside the current price and earns nothing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Depth is measured, not read.&lt;/strong&gt; We simulate trades from $1k to $10M against the live pool and record what each one costs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The answer is the ratio.&lt;/strong&gt; Take the largest trade the pool fills while losing under 1% to price movement, and divide it by TVL. USDC/WETH holds about $106M, and the largest such trade was $1M: about 0.94% of its TVL. In v3 that is normal, because most of the money sits outside the current price. A scam pool claiming billions can't fill even a $1,000 trade, so it fails outright.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The question an LP actually asks
&lt;/h2&gt;

&lt;p&gt;A liquidity provider deposits two tokens into a pool and earns a share of the fee on every trade that passes through it. In Uniswap v3 they also choose a price range, and they only earn while the price stays inside it. In exchange, they hold whatever the traders leave behind. When one token falls, traders sell it into the pool, and the LP ends up holding more of it. If the price drops out of their range, they hold only the token that fell, and earn nothing until the price comes back.&lt;/p&gt;

&lt;p&gt;So an LP is asking three things. Does the pool hold a real two-sided market? Does trade actually flow through it? Is the fee worth the risk? "How big is the pool?" is a stand-in for all three, and TVL is the number people normally reach for. An agent with a list of pools will sort by &lt;code&gt;totalValueLockedUSD&lt;/code&gt; unless something stops it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why TVL misleads
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Fake TVL
&lt;/h3&gt;

&lt;p&gt;Here are the three largest Uniswap v3 pools on Ethereum mainnet by TVL, as our &lt;a href="https://thegraph.com/docs/en/subgraphs/developing/subgraphs/" rel="noopener noreferrer"&gt;subgraph&lt;/a&gt; reported them at block 25,835,635. A subgraph is an index of onchain data, built with The Graph, that you can query like a database.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;TVL&lt;/th&gt;
&lt;th&gt;Pool&lt;/th&gt;
&lt;th&gt;Volume, all time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;$1,945.56B&lt;/td&gt;
&lt;td&gt;Uniswap v3 USDT/USDT 1%&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$3.20B&lt;/td&gt;
&lt;td&gt;Uniswap v3 TRUMP/WETH 0.3%&lt;/td&gt;
&lt;td&gt;$1.53&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$1.24B&lt;/td&gt;
&lt;td&gt;Uniswap v3 USDT/WETH 1%&lt;/td&gt;
&lt;td&gt;$4.93&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;None of these is a real venue. The first pairs a scam token that calls itself &lt;code&gt;USDT&lt;/code&gt; against the real USDT. It holds two trillion of the fake and none of the real one.&lt;/p&gt;

&lt;p&gt;The indexer's arithmetic isn't wrong. To price a token with no market of its own, the indexer borrows the price of what it's paired with. Pair a worthless token with a dollar and it inherits a plausible price. A plausible price times an absurd balance is an absurd TVL.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real but idle TVL
&lt;/h3&gt;

&lt;p&gt;The second failure looks the same and is harder to spot, because the money is real.&lt;/p&gt;

&lt;p&gt;Those price ranges are what Uniswap calls &lt;strong&gt;concentrated liquidity&lt;/strong&gt;. Instead of spreading their tokens across every possible price, LPs put them where they expect trading to happen, say WETH between $2,000 and $3,000. Inside that range their capital works much harder. Outside it, it does nothing. In &lt;a href="https://developers.uniswap.org/docs/get-started/concepts/liquidity-providers/concentrated-liquidity" rel="noopener noreferrer"&gt;Uniswap's words&lt;/a&gt;: "when the price exits a position's interval, the position's liquidity is no longer active and no longer earns fees."&lt;/p&gt;

&lt;p&gt;TVL counts every position, in range or not. A trade only meets the ones around the current price. So even on a healthy pool, most of the TVL is not what a trader or a new LP is dealing with. What counts is how much liquidity sits around the current price: its &lt;strong&gt;depth&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measuring depth
&lt;/h2&gt;

&lt;p&gt;Depth is how much a pool can absorb before the price moves too far. You can't read it from an index. You ask the pool.&lt;/p&gt;

&lt;p&gt;Uniswap's &lt;strong&gt;QuoterV2&lt;/strong&gt; contract lets you simulate "if I swapped this much, what would I get back?" without making the trade. The analyst asks it five times, at $1k, $10k, $100k, $1M and $10M, all against the same block so the five answers describe one state of the pool. We call that a &lt;strong&gt;depth ladder&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The quoter works in tokens, not dollars&lt;/strong&gt;, so each size is converted with the token's price first: $1k of USDC is about 1,000 USDC.&lt;/p&gt;

&lt;p&gt;Here is the real ladder for USDC/WETH 0.05% at block 25,925,794:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Trade size&lt;/th&gt;
&lt;th&gt;WETH out&lt;/th&gt;
&lt;th&gt;Slippage&lt;/th&gt;
&lt;th&gt;Initialized ticks crossed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;$1k&lt;/td&gt;
&lt;td&gt;0.398654&lt;/td&gt;
&lt;td&gt;0.000%&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$10k&lt;/td&gt;
&lt;td&gt;3.986406&lt;/td&gt;
&lt;td&gt;0.003%&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$100k&lt;/td&gt;
&lt;td&gt;39.850218&lt;/td&gt;
&lt;td&gt;0.038%&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$1M&lt;/td&gt;
&lt;td&gt;397.118445&lt;/td&gt;
&lt;td&gt;0.385%&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$10M&lt;/td&gt;
&lt;td&gt;3,793.724629&lt;/td&gt;
&lt;td&gt;4.837%&lt;/td&gt;
&lt;td&gt;125&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Slippage&lt;/strong&gt; is how much worse the price got compared with the $1k trade, which is small enough to move the price barely at all. We compare against the pool's own price rather than a market price from elsewhere, because the question is what this pool does to a trade, not whether it's priced fairly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ticks&lt;/strong&gt; are the price steps v3 divides its range into, and an initialized tick is one where some LP's range starts or ends. Crossing 125 of them means the $10M trade walked through 125 boundaries of LP ranges to get filled. That turns "the price got worse" into a picture of where the liquidity sits.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The direction of the quote matters too. The analyst always quotes the trade that drains the scarcer token. Quote the scam pool the other way, selling real USDT to buy the fake, and two trillion tokens make it look bottomless.&lt;/p&gt;

&lt;h2&gt;
  
  
  The ratio neither source gives alone
&lt;/h2&gt;

&lt;p&gt;The subgraph supplies the claimed TVL. The quoter supplies the usable depth: the largest trade on the ladder that stays within 1% slippage. Divide one by the other.&lt;/p&gt;

&lt;p&gt;On USDC/WETH, $1M was the largest trade inside 1%, against a TVL of about $106M. That is &lt;strong&gt;0.944%&lt;/strong&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Depth over TVL&lt;/th&gt;
&lt;th&gt;What it says&lt;/th&gt;
&lt;th&gt;Signal&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1% or more&lt;/td&gt;
&lt;td&gt;TVL and depth agree within a plausible ratio&lt;/td&gt;
&lt;td&gt;pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.1% to 1%&lt;/td&gt;
&lt;td&gt;Most of the TVL isn't reachable: normal for v3, but worth knowing&lt;/td&gt;
&lt;td&gt;warn&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;below 0.1%, or nothing fills&lt;/td&gt;
&lt;td&gt;TVL isn't describing the pool&lt;/td&gt;
&lt;td&gt;fail&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;USDC/WETH lands in the middle. That's not a red flag: it's what concentrated liquidity looks like. But an LP sizing a position off the headline TVL is looking at a number about a hundred times the depth that actually wins trades. The scam pools land at the bottom, because a pool claiming $1.9 trillion can't fill $1,000.&lt;/p&gt;

&lt;p&gt;The ratio moves. Within three hours the same pool's TVL read $106.68M, $105.90M and $105.72M, and the ratio went from 0.944% to 0.946%. That's why every number here carries the block it was read at.&lt;/p&gt;

&lt;p&gt;The denominator can also come from the chain instead of an indexer. We published the analyst as a &lt;a href="https://bazantic.com/docs/recipes" rel="noopener noreferrer"&gt;Bazantic&lt;/a&gt; Recipe, which chains it with a tool that reads the pool's token balances on chain. On USDC/WETH 0.3% that found $32.36M actually held against $32.73M claimed: close, as it should be for a healthy pool.&lt;/p&gt;

&lt;h2&gt;
  
  
  History still matters
&lt;/h2&gt;

&lt;p&gt;The quote says what the pool can do now. The subgraph says what it has done, and some risks only show up over time. The analyst checks seven signals.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Signal&lt;/th&gt;
&lt;th&gt;What it asks&lt;/th&gt;
&lt;th&gt;Source&lt;/th&gt;
&lt;th&gt;Structural&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Inventory balance&lt;/td&gt;
&lt;td&gt;Is the pool two-sided, or a pile of one token?&lt;/td&gt;
&lt;td&gt;subgraph&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Executable depth&lt;/td&gt;
&lt;td&gt;Does a real-size trade execute, and at what cost?&lt;/td&gt;
&lt;td&gt;quoter&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Depth vs TVL&lt;/td&gt;
&lt;td&gt;How much of the TVL can a trade reach?&lt;/td&gt;
&lt;td&gt;both&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Trading continuity&lt;/td&gt;
&lt;td&gt;Does it trade steadily, or in bursts and silence?&lt;/td&gt;
&lt;td&gt;subgraph&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Slippage curve&lt;/td&gt;
&lt;td&gt;Does the cost grow smoothly, or fall off a cliff?&lt;/td&gt;
&lt;td&gt;quoter&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fee return&lt;/td&gt;
&lt;td&gt;What are LPs actually earning, per year?&lt;/td&gt;
&lt;td&gt;subgraph&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LP concentration&lt;/td&gt;
&lt;td&gt;How many positions are open? One is someone's inventory.&lt;/td&gt;
&lt;td&gt;subgraph&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The &lt;strong&gt;structural&lt;/strong&gt; signals decide whether the pool is a market at all, so any one of them failing means &lt;code&gt;AVOID&lt;/code&gt;, whatever the rest say. A big TVL doesn't buy that back, because it comes from the same reserves that failed the test. TRUMP/WETH fails two on its history alone: it holds 1.5 billion TRUMP against 0.00063 WETH, and it traded in 3 hours out of 24.&lt;/p&gt;

&lt;p&gt;The other three can't sink a pool on their own. One failure among them, or two warnings anywhere, make the verdict &lt;code&gt;CAUTION&lt;/code&gt;. Otherwise it's &lt;code&gt;ACCEPTABLE&lt;/code&gt;. USDC/WETH, with its one depth warning, came out &lt;code&gt;ACCEPTABLE&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  An answer that says what it doesn't know
&lt;/h2&gt;

&lt;p&gt;The buyer is an agent. It can't ask a follow-up question, so everything it would want to ask has to be in the answer. Each verdict comes with a confidence score and a list of caveats, and the confidence drops for stated reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A signal couldn't be measured.&lt;/strong&gt; Each unknown costs confidence. If two structural signals are unknown, there is no verdict at all: the rating is &lt;code&gt;INSUFFICIENT_DATA&lt;/code&gt;, so a missing measurement never passes for a measured concern.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No live quote.&lt;/strong&gt; A large cut, because nothing was checked against the pool as it is now.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Short history.&lt;/strong&gt; Fewer hours of data than the analyst wants.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A stale index.&lt;/strong&gt; A subgraph can fall behind the chain. That never fails a pool, because "the data is old" is a different problem from "the pool is bad". It lowers confidence and the summary says so: "Where the live quote and the history disagree, believe the quote."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Circular prices.&lt;/strong&gt; The ladder's dollar sizes come from the subgraph's price for the token, which for a thin pool was derived from that same pool. The token amounts are exact; the dollar labels are only as good as that price.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The USDC/WETH verdict was &lt;code&gt;ACCEPTABLE&lt;/code&gt; at 75% confidence. Our subgraph was 13.1 days behind at the time, and the ladder was priced with the subgraph's own price. Both are in the caveats.&lt;/p&gt;

&lt;p&gt;The same logic shapes the two tiers Turnstile sells. &lt;strong&gt;Standard ($0.07)&lt;/strong&gt; answers from the subgraph alone. Without a quote, executable depth and depth-vs-TVL are both unknown, and both are structural, so this tier can reject a pool on its history but can never approve one. That's the point: screen cheaply, and only pay for a live quote on pools history hasn't ruled out. &lt;strong&gt;Premium ($0.35)&lt;/strong&gt; adds the live ladder and the full evidence behind the verdict, about 9KB of JSON. &lt;a href="https://ignaciopastorsanchez.com/blog/chainlink-cre-confidential-workflows-sell-the-answer" rel="noopener noreferrer"&gt;Part 8&lt;/a&gt; covers how a hash of that evidence goes on chain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prices still come from the indexer.&lt;/strong&gt; The ratio catches a fake TVL by its missing depth, but every dollar figure is still the subgraph's price. For thin pools that price can be circular.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One pool at a time.&lt;/strong&gt; QuoterV2 quotes one pool, which is the question an LP asks. A trader routing across many pools gets a better price than this ladder shows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Five rungs are coarse.&lt;/strong&gt; Usable depth is the largest rung within 1%, so the real figure for USDC/WETH lies somewhere between $1M and $10M.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A snapshot.&lt;/strong&gt; Depth changes with every swap and every LP who moves a range. The verdict is true at its block.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More from this series: &lt;a href="https://ignaciopastorsanchez.com/blog/x402-on-hedera-blocky402-paid-http" rel="noopener noreferrer"&gt;x402 on Hedera&lt;/a&gt;, &lt;a href="https://ignaciopastorsanchez.com/blog/gasless-nanopayments-eip3009-circle-gateway-arc" rel="noopener noreferrer"&gt;gasless nanopayments on Arc&lt;/a&gt;, &lt;a href="https://ignaciopastorsanchez.com/blog/erc8004-agent-discovery-substreams" rel="noopener noreferrer"&gt;ERC-8004 discovery with Substreams&lt;/a&gt;, &lt;a href="https://ignaciopastorsanchez.com/blog/privy-spending-mandates-key-quorums" rel="noopener noreferrer"&gt;Privy spending mandates&lt;/a&gt;, &lt;a href="https://ignaciopastorsanchez.com/blog/world-id-selfie-check-abuse-control" rel="noopener noreferrer"&gt;World ID as abuse control&lt;/a&gt;, &lt;a href="https://ignaciopastorsanchez.com/blog/chainlink-cre-confidential-workflows-sell-the-answer" rel="noopener noreferrer"&gt;Chainlink CRE Confidential Workflows&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Turnstile repository&lt;/a&gt;: the analyst in &lt;code&gt;seller/analyst/&lt;/code&gt;, with the scorer in &lt;code&gt;scoring.ts&lt;/code&gt; and the dated verification notes behind every figure here.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developers.uniswap.org/docs/get-started/concepts/liquidity-providers/concentrated-liquidity" rel="noopener noreferrer"&gt;Uniswap docs: Concentrated liquidity&lt;/a&gt;: range-bound liquidity that stops earning fees out of range.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/IQuoterV2.sol" rel="noopener noreferrer"&gt;Uniswap v3-periphery IQuoterV2.sol&lt;/a&gt;: &lt;code&gt;quoteExactInputSingle&lt;/code&gt;, which returns the amount out and the initialized ticks crossed.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://thegraph.com/docs/en/subgraphs/developing/subgraphs/" rel="noopener noreferrer"&gt;The Graph docs: Subgraphs&lt;/a&gt;: what a subgraph is.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/messari/subgraphs/blob/master/schema-dex-amm-extended.graphql" rel="noopener noreferrer"&gt;Messari schema-dex-amm-extended.graphql&lt;/a&gt;: the standard DEX schema our subgraph implements.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://bazantic.com/docs/recipes" rel="noopener noreferrer"&gt;Bazantic docs: Recipes&lt;/a&gt; and &lt;a href="https://api.bazantic.com/v1/recipes/uniswap-pool-safety-analysis" rel="noopener noreferrer"&gt;the published Recipe&lt;/a&gt;: the analyst chained with an on-chain balance read.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;That was the last part of the series.&lt;/strong&gt; Start again from &lt;a href="https://ignaciopastorsanchez.com/blog/x402-on-hedera-blocky402-paid-http" rel="noopener noreferrer"&gt;part 1, x402 on Hedera: what a paid HTTP request is made of&lt;/a&gt;, or read the &lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Turnstile project page&lt;/a&gt; for the whole build.&lt;/p&gt;

</description>
      <category>defi</category>
      <category>web3</category>
      <category>ai</category>
      <category>agents</category>
    </item>
    <item>
      <title>Sell the answer, keep the method: Chainlink CRE Confidential Workflows</title>
      <dc:creator>Ignacio Pastor Sánchez</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:37:13 +0000</pubDate>
      <link>https://dev.to/ignacio_pastor/sell-the-answer-keep-the-method-chainlink-cre-confidential-workflows-h17</link>
      <guid>https://dev.to/ignacio_pastor/sell-the-answer-keep-the-method-chainlink-cre-confidential-workflows-h17</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 8 of 9 in the &lt;a href="https://ignaciopastorsanchez.com/blog/series/turnstile" rel="noopener noreferrer"&gt;Turnstile series&lt;/a&gt;: building a paid lane for onchain data agents.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;Turnstile sells one answer per payment: is this Uniswap pool safe to provide liquidity to? A good answer has an awkward property. Publish how you got it and nobody needs to pay you. Hide it and nobody can trust it.&lt;/p&gt;

&lt;p&gt;Confidential compute is the way out: run the method where nobody can look, and prove that it ran. Chainlink's version is the &lt;strong&gt;Confidential Workflow&lt;/strong&gt;, part of the Chainlink Runtime Environment (CRE).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What it is.&lt;/strong&gt; A CRE workflow that runs part of its logic inside a secure enclave, a hardware-isolated environment that even the machine's operator cannot look into.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What it hides.&lt;/strong&gt; Data, not code. Secrets, inputs and intermediate values stay inside; the workflow's code is public. So if your edge is worth hiding, it has to be data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How we used it.&lt;/strong&gt; The scorer's logic is public. Its tuned thresholds go in as a secret. Only a short verdict and a hash of the evidence come out.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The code is at &lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;github.com/IpastorSan/turnstile&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem: selling an answer whose method is the edge
&lt;/h2&gt;

&lt;p&gt;The rest of this series is about how an agent pays for data: &lt;a href="https://ignaciopastorsanchez.com/blog/x402-on-hedera-blocky402-paid-http" rel="noopener noreferrer"&gt;x402 on Hedera&lt;/a&gt;, &lt;a href="https://ignaciopastorsanchez.com/blog/gasless-nanopayments-eip3009-circle-gateway-arc" rel="noopener noreferrer"&gt;gasless nanopayments on Arc&lt;/a&gt;, &lt;a href="https://ignaciopastorsanchez.com/blog/chain-agnostic-x402-seller-payment-rails" rel="noopener noreferrer"&gt;a seller that takes any rail&lt;/a&gt;, and discovery through &lt;a href="https://ignaciopastorsanchez.com/blog/erc8004-agent-discovery-substreams" rel="noopener noreferrer"&gt;ERC-8004&lt;/a&gt; and &lt;a href="https://ignaciopastorsanchez.com/blog/ensv2-agent-offer-records-hot-cold-keys" rel="noopener noreferrer"&gt;ENS&lt;/a&gt;. The product being sold is a &lt;a href="https://ignaciopastorsanchez.com/blog/the-graph-uniswap-paid-liquidity-analyst" rel="noopener noreferrer"&gt;liquidity analyst&lt;/a&gt; that reads a pool's history and live depth and answers one question: is it safe to LP?&lt;/p&gt;

&lt;p&gt;Under the payments sits an economic problem. If the analyst is good, publishing its method gives away the reason to pay. If you keep it private, the buyer has to take a stranger's word on faith. A verdict you can't check isn't worth much, and one you can fully reproduce isn't worth buying.&lt;/p&gt;

&lt;p&gt;We needed something in between: a verdict the buyer can check, from a method they can't copy.&lt;/p&gt;

&lt;h2&gt;
  
  
  What confidential compute is
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;trusted execution environment&lt;/strong&gt; (TEE) is a part of a processor that runs code in isolation. Its memory is encrypted, and neither the operating system nor the person who owns the machine can read it while the code runs. A running instance is called an &lt;strong&gt;enclave&lt;/strong&gt;. AWS Nitro Enclaves is one example, and it is the one Chainlink uses today.&lt;/p&gt;

&lt;p&gt;A TEE gives you two things.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Confidentiality.&lt;/strong&gt; What happens inside can't be read from outside while it runs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Attestation.&lt;/strong&gt; The hardware signs a statement saying which program is running. Anyone can check that signature and know which program produced an output, and that nobody tampered with it along the way.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It does not give you everything. The output is only as private as you make it: whatever the code logs, returns or sends leaves the enclave. You also trust the hardware vendor, and side-channel attacks have broken enclaves before.&lt;/p&gt;

&lt;p&gt;A TEE on its own also leaves one job to the buyer: checking the attestation. A seller could run the scorer in an enclave and publish the signed statement, but then every buyer has to verify it themselves and trust that the seller published the right one. That is the job Chainlink takes on.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Chainlink's Confidential Workflows work
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;Chainlink Runtime Environment&lt;/strong&gt; (CRE) is Chainlink's platform for running your own code on its oracle networks, instead of only reading the data they publish. The unit of code is a &lt;strong&gt;workflow&lt;/strong&gt;: a program, written in Go or TypeScript and compiled to WebAssembly, that runs when a trigger fires, such as a schedule, an HTTP request or an onchain event. A &lt;strong&gt;Workflow DON&lt;/strong&gt; (decentralized oracle network, a set of independent nodes) runs it. Each node executes the step and the nodes reach consensus on the result. That is good for trust and bad for secrets, because every node operator can, in principle, see what is being computed.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;Confidential Workflow&lt;/strong&gt; marks one handler to run inside an enclave instead. Per &lt;a href="https://docs.chain.link/cre/concepts/confidential-workflows" rel="noopener noreferrer"&gt;Chainlink's docs&lt;/a&gt;, it goes like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The trigger fires&lt;/strong&gt;, and the Workflow DON hands the request to an enclave.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The handler runs inside the enclave.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Secrets are fetched when the code needs them.&lt;/strong&gt; They come from the &lt;strong&gt;Vault DON&lt;/strong&gt;, Chainlink's network for storing secrets, and are decrypted only inside the enclave.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The code crosses back to the DON&lt;/strong&gt; when it needs something only the DON can do, such as signing a report to put on chain. From that point on, whatever crosses is ordinary data, not confidential.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The DON verifies the enclave's attestation by consensus.&lt;/strong&gt; The workflow only completes once that check passes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A Forwarder contract delivers the signed report&lt;/strong&gt; to your consumer contract on chain.
&lt;/li&gt;
&lt;/ol&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
  D1["Workflow DON&amp;lt;br/&amp;gt;a trigger fires"] --&amp;gt;|"hands the request over"| ENC["Enclave&amp;lt;br/&amp;gt;runs the confidential handler"]
  V["Vault DON"] -.-&amp;gt;|"secrets, decrypted only inside"| ENC
  ENC --&amp;gt;|"only what you choose to send out"| D2["Workflow DON&amp;lt;br/&amp;gt;checks the attestation, signs the report"]
  D2 --&amp;gt; F["Forwarder contract"]
  F --&amp;gt; C["Your consumer contract"]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The consumer contract is where the trust becomes checkable on chain. It accepts reports only from the Forwarder, and it can also require a specific workflow id and owner. A buyer doesn't verify enclave signatures. They read a contract that only a verified workflow can write to.&lt;/p&gt;

&lt;p&gt;The docs are precise about what this protects:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Protected&lt;/th&gt;
&lt;th&gt;Not protected&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Secrets the Vault DON releases into the enclave&lt;/td&gt;
&lt;td&gt;The workflow's source code and compiled binary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inputs and intermediate values you keep inside&lt;/td&gt;
&lt;td&gt;Triggers, chain reads and chain writes, which always run on the DON&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The enclave's memory while it runs&lt;/td&gt;
&lt;td&gt;Reports, logs and anything else you send out&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The first row of the right-hand column is the one that shaped our design. In Chainlink's words: "Your handler's source code and compiled binary are not confidential just because part of its logic runs inside an enclave."&lt;/p&gt;

&lt;p&gt;Compared with a classic oracle, the thing being agreed on is different. An oracle network agrees on a public fact, like a price, that every node can check. Here nobody but the enclave sees the inputs, so the network cannot agree on the answer. What it agrees on is that a verified enclave ran this program.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it fits Turnstile
&lt;/h2&gt;

&lt;p&gt;If the code is public, a secret threshold written into the code is public too. So we sorted each piece by whether it has to stay secret.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;th&gt;How it moves&lt;/th&gt;
&lt;th&gt;Secret?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Calibration&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;the tuned thresholds&lt;/td&gt;
&lt;td&gt;into the enclave, as a Vault DON secret&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Evidence&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;the pool's history and live depth&lt;/td&gt;
&lt;td&gt;into the enclave, fetched with a token held in the Vault&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scorer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;which signals exist and how they combine&lt;/td&gt;
&lt;td&gt;compiled into the workflow&lt;/td&gt;
&lt;td&gt;no, on purpose&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Verdict&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;rating, confidence, which tests failed or warned, a hash of the evidence&lt;/td&gt;
&lt;td&gt;out of the enclave, to the DON and then on chain&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The shape of the judgement should be public: which seven signals the scorer checks, and which ones force an &lt;code&gt;AVOID&lt;/code&gt; verdict on their own. That is what makes a result auditable instead of an oracle you take on faith.&lt;/p&gt;

&lt;p&gt;The calibration is different. It is what running the scorer against real pools taught us. Take trading continuity, one of the seven signals: it counts how many of the last 24 hours saw a trade. Below half, the pool gets a warning for trading in bursts. At or below a lower cutoff, it fails outright, because that is not a market. We first set that cutoff at 10% of hours. Then a real TRUMP/WETH pool traded in 3 hours out of 24, $1.54 of volume in total, and at 10% it only got the warning. We raised the cutoff to 20%, and that pool now fails as it should. &lt;strong&gt;That tuning is the analyst's edge, so it lives in the Vault&lt;/strong&gt;. The numbers in our public repo are a reference set; a seller's own set is the secret.&lt;/p&gt;

&lt;p&gt;What goes on chain is deliberately small. The full verdict, with a reasoning paragraph and numbers for each signal, is what the buyer pays for over x402, off chain. The chain holds only the rating, the confidence, which tests failed or warned, the time the evidence describes, and a hash of the evidence. The hash is what ties the two together. A buyer who paid has the evidence, hashes it and asks the contract whether the settled verdict commits to that exact hash. If it does, the verdict is about the data they hold. If not, the seller swapped the evidence, and the buyer can prove it. Someone who hasn't paid learns nothing from a hash.&lt;/p&gt;

&lt;h3&gt;
  
  
  Trust is not a boolean
&lt;/h3&gt;

&lt;p&gt;A verdict being on chain doesn't by itself mean an enclave produced it. That depends on who delivered it and on what the consumer contract checks. So the premium answer doesn't carry a &lt;code&gt;verified: true&lt;/code&gt; flag. It tells the buyer which of four cases they are in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;None.&lt;/strong&gt; No verdict for this pool is on chain. The buyer has only the seller's word.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-delivered.&lt;/strong&gt; The contract accepts reports from an address other than Chainlink's Forwarder, so someone wrote this verdict directly. Our one verdict on Sepolia is this kind: we sent it ourselves to test the contract. It shows that the format and the evidence hash work, and proves nothing about an enclave.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forwarded, not pinned.&lt;/strong&gt; It came through the Forwarder, so a Chainlink DON signed it, but the contract doesn't name the workflow it trusts. Any CRE workflow could have written it. Pinning needs the workflow's id, which only exists once the workflow is deployed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Attested.&lt;/strong&gt; Through the Forwarder, from the one workflow the contract names. This is the only case that means our scorer ran inside an enclave.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Limitations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Access.&lt;/strong&gt; Confidential Workflows is a private beta that needs enrollment through Chainlink. Deploying any CRE workflow also needs approval, separately.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The code isn't confidential.&lt;/strong&gt; Keeping the logic itself secret is listed as a future feature. Today, if your edge is in the code, a confidential workflow doesn't hide it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shared enclaves.&lt;/strong&gt; Several confidential workflows can run in the same enclave, kept apart by the WebAssembly runtime. One enclave per workflow is planned.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The usual TEE trust.&lt;/strong&gt; You trust the hardware, and the docs warn that side-channel attacks may leak information.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leaks are on you.&lt;/strong&gt; Logs, outputs and outgoing requests leave the enclave. Even our verdict says which tests failed, which hints at what the scorer cares about.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.chain.link/cre" rel="noopener noreferrer"&gt;Chainlink CRE overview&lt;/a&gt;: workflows in Go or TypeScript, run by a decentralized oracle network that reaches consensus on every result.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.chain.link/cre/concepts/confidential-workflows" rel="noopener noreferrer"&gt;CRE Confidential Workflows concept&lt;/a&gt;: the six steps, what is and isn't protected, code not confidential, shared enclaves, side channels, private beta.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.chain.link/cre/account/confidential-workflows-access" rel="noopener noreferrer"&gt;Requesting Confidential Workflows access&lt;/a&gt;: private beta, separate from deploy access, simulator usable meanwhile.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.chain.link/cre/guides/workflow/secrets" rel="noopener noreferrer"&gt;Using secrets&lt;/a&gt;: local secrets in simulation, the Vault DON when deployed.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.chain.link/cre/guides/operations/simulating-workflows" rel="noopener noreferrer"&gt;Simulating workflows&lt;/a&gt;: chain writes are a dry run by default.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.chain.link/cre/guides/operations/deploying-workflows" rel="noopener noreferrer"&gt;Deploying workflows&lt;/a&gt;: deployment requires approval.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.chain.link/cre/guides/workflow/using-evm-client/forwarder-directory-ts" rel="noopener noreferrer"&gt;Forwarder directory (TS)&lt;/a&gt;: the Sepolia Forwarder our production contract is pinned to.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/smartcontractkit/cre-sdk-typescript" rel="noopener noreferrer"&gt;smartcontractkit/cre-sdk-typescript&lt;/a&gt;: the TypeScript SDK and &lt;code&gt;cre.handlerInTee&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.x402.org/" rel="noopener noreferrer"&gt;x402 docs&lt;/a&gt;: the HTTP 402 payment standard Turnstile sells over.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://sepolia.etherscan.io/address/0xfE95CD0f710DDC5ceED0e93c4e25412Dc3d8eEeA" rel="noopener noreferrer"&gt;Production consumer on Sepolia&lt;/a&gt;: pinned to the CRE Forwarder, no reports received.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://sepolia.etherscan.io/tx/0x8ee33bb38563ed88836eaf6e2b7011c1350ef64390f7307691da24bd45e909b8" rel="noopener noreferrer"&gt;Stand-in settlement on Sepolia&lt;/a&gt;: the one verdict we delivered ourselves.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Turnstile repository&lt;/a&gt;: the workflow in &lt;code&gt;seller/cre/&lt;/code&gt;, the consumer in &lt;code&gt;contracts/src/VerdictConsumer.sol&lt;/code&gt;, and the simulator transcripts in &lt;code&gt;docs/cre-confidential-workflow.md&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Next in the series:&lt;/strong&gt; &lt;a href="https://ignaciopastorsanchez.com/blog/the-graph-uniswap-paid-liquidity-analyst" rel="noopener noreferrer"&gt;Selling a liquidity verdict: The Graph, Uniswap QuoterV2, and the gap between TVL and depth&lt;/a&gt;, part 9 of 9.&lt;/p&gt;

</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>ai</category>
      <category>security</category>
    </item>
    <item>
      <title>Spending mandates for agents: the wallet can never raise its own limit</title>
      <dc:creator>Ignacio Pastor Sánchez</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:37:05 +0000</pubDate>
      <link>https://dev.to/ignacio_pastor/spending-mandates-for-agents-the-wallet-can-never-raise-its-own-limit-4lfk</link>
      <guid>https://dev.to/ignacio_pastor/spending-mandates-for-agents-the-wallet-can-never-raise-its-own-limit-4lfk</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 7 of 9 in the &lt;a href="https://ignaciopastorsanchez.com/blog/series/turnstile" rel="noopener noreferrer"&gt;Turnstile series&lt;/a&gt;: building a paid lane for onchain data agents.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;As part of Turnstile we built an agent that buys answers over paid HTTP (x402-style). An agent that pays needs a spending limit, and the limit is worthless unless one rule holds:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The key that spends can never raise its own limit.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A limit exists for the day the agent misbehaves: a prompt injection, a bad dependency, a leaked key. Whoever controls the agent's key can then do anything that key can do. If raising the limit is one of those things, they raise it first and spend second.&lt;/p&gt;

&lt;p&gt;This is how we made that true without writing the enforcement ourselves.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Two wallets.&lt;/strong&gt; A &lt;strong&gt;Privy organization wallet&lt;/strong&gt; that funds the agent, and the &lt;strong&gt;agent wallet&lt;/strong&gt;, which only signs offchain authorizations and has never sent a transaction (nonce 0).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Two key quorums.&lt;/strong&gt; The org wallet is owned by a &lt;strong&gt;1-of-2 operations quorum&lt;/strong&gt;. The spend policy that caps it is owned by a &lt;strong&gt;separate 2-of-2 board quorum&lt;/strong&gt;. Funding the agent takes one person. Changing the rules takes two.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Raising the cap is a policy &lt;code&gt;PATCH&lt;/code&gt;.&lt;/strong&gt; Privy refuses it with one signature (&lt;code&gt;401&lt;/code&gt;) and accepts it with two.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Who holds the approval keys matters.&lt;/strong&gt; Ours are made in the browser and our server only sees the public half, but passkeys or Privy users would be stronger.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rough edges.&lt;/strong&gt; A final DENY rule blocks everything, address matching is case-sensitive, and a denial doesn't say which rule fired.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The code is at &lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;github.com/IpastorSan/turnstile&lt;/a&gt;, and the &lt;code&gt;/mandate&lt;/code&gt; page is on camera in the &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/docs/demo/turnstile-demo.mp4" rel="noopener noreferrer"&gt;demo video&lt;/a&gt;. Everything below runs on testnet.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem: an agent with a card and no manager
&lt;/h2&gt;

&lt;p&gt;The usual first design for a paying agent goes like this. The agent has a wallet. Some config says "max $1 per day". The agent's code checks the config before paying. The problem is that the thing enforcing the limit and the thing being limited share a process. A prompt injection, a bad dependency or a leaked &lt;code&gt;.env&lt;/code&gt; defeats both at once, because whoever can spend can also edit the check.&lt;/p&gt;

&lt;p&gt;In Turnstile, the limits a buyer gives its agent are a &lt;strong&gt;mandate&lt;/strong&gt;: a total spend cap, a ceiling per query and a list of sellers it may pay. The agent's code checks the mandate before every payment, but that check is exactly the one a compromised agent skips.&lt;/p&gt;

&lt;p&gt;The agent can only spend what is in its wallet, and the only way money gets in is a deposit from the buyer organization's wallet. Cap that deposit and a compromised agent can't overspend: it runs out of money instead.&lt;/p&gt;

&lt;p&gt;So we set a stricter goal. Assume our server is fully compromised, app secret included. What should still hold?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;No deposit to the agent can exceed the mandate's cap.&lt;/li&gt;
&lt;li&gt;Nobody holding our server's secrets can raise that cap.&lt;/li&gt;
&lt;li&gt;Raising it needs more than one human.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The agent never asks for money. An operator tops it up by hand, one deposit at a time (&lt;code&gt;scripts/arc-setup.ts&lt;/code&gt;), and the agent spends what it holds; inside that balance, only its own checks stop it. So the mandate doesn't make a compromised agent behave. It bounds the loss to what was deposited.&lt;/p&gt;

&lt;p&gt;Topping up by hand is fine for a testnet demo, but it does not scale. Automating it means a job that holds an operations key, and if that job runs on our server, a compromised server can approve capped deposits as often as it likes. At that point the cap has to cover the running total, not just each deposit.&lt;/p&gt;

&lt;h2&gt;
  
  
  One direction of authority
&lt;/h2&gt;

&lt;p&gt;On the buyer side, authority runs one way: from the humans who set the rules, through the wallet that funds the agent, down to the agent that spends. Each layer may authorize less than the one above it.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;th&gt;May authorize&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Board quorum&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Two operators, 2-of-2, owning the mandate policy&lt;/td&gt;
&lt;td&gt;Raising the cap&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Operations quorum&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Two operators, 1-of-2, owning the org wallet&lt;/td&gt;
&lt;td&gt;Funding the agent, within the cap&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Org wallet&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A &lt;strong&gt;Privy server wallet&lt;/strong&gt; for the buyer organization&lt;/td&gt;
&lt;td&gt;Deposits to the agent, and only what the policy allows&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Agent wallet&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The buyer agent's wallet on Arc&lt;/td&gt;
&lt;td&gt;Nothing. It spends inside the mandate&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The seller side has the same split: its hot key can change the price but not the payout address (see &lt;a href="https://ignaciopastorsanchez.com/blog/ensv2-agent-offer-records-hot-cold-keys" rel="noopener noreferrer"&gt;The offer is the name: ENSv2 records and a key split the chain enforces&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The agent wallet is the interesting one. The agent pays through Circle Gateway by signing EIP-3009 authorizations offchain, and the batcher submits them. The agent never submits a transaction, so it has no gas and no way to deposit, withdraw or widen anything.&lt;/p&gt;

&lt;p&gt;That leaves one tap that fills the agent's balance, and the agent doesn't control it. The org wallet calls &lt;code&gt;depositFor(token, agent, value)&lt;/code&gt; on Circle's GatewayWallet contract: the org wallet sends the transaction and pays the gas, and the balance is credited to the agent. Cap that call and the mandate is capped at its source.&lt;/p&gt;

&lt;h2&gt;
  
  
  The org wallet: a server wallet with a spending policy
&lt;/h2&gt;

&lt;p&gt;The org wallet is a Privy server wallet: Privy holds its private key, and we ask Privy to sign with it. A deposit goes like this: our code builds the &lt;code&gt;depositFor&lt;/code&gt; transaction and sends it, unsigned, to Privy's API, together with an operator's signature approving the request. Privy checks that signature against the wallet's owners, checks the transaction against the wallet's policy, and only if both pass does it sign. We get back a signed transaction and broadcast it to Arc ourselves.&lt;/p&gt;

&lt;p&gt;Three things follow from that.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;No org private key exists on our machine.&lt;/strong&gt; It is reconstituted inside Privy's enclave, so reading &lt;code&gt;.env&lt;/code&gt; gives nobody the power to spend.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Every signature is checked against a policy first.&lt;/strong&gt; Privy's docs say the enclave "evaluates all policy rules in a tamper-proof environment before signing."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The owner is a group of people, not a key in a file.&lt;/strong&gt; In Privy, a wallet's owner is whoever must approve each request to sign. Ours is a &lt;em&gt;key quorum&lt;/em&gt;: the public keys of our operators plus a threshold, how many of them must sign. A request without enough operator signatures is refused, however much of our server an attacker controls.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The policy is two ALLOW rules and nothing else:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Fund the agent, within the mandate'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'eth_signTransaction'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;conditions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;field_source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'ethereum_transaction'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'to'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;operator&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'eq'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;gateway&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;field_source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'ethereum_calldata'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'depositFor.depositor'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;abi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;DEPOSIT_FOR_ABI&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;operator&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'eq'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;agent&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;field_source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'ethereum_calldata'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'depositFor.value'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;abi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;DEPOSIT_FOR_ABI&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;operator&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'lte'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cap&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'ALLOW'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// ...a second rule caps approve(spender = GatewayWallet, value &amp;lt;= cap)&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Trimmed from &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/buyer/mandate/policy.ts" rel="noopener noreferrer"&gt;&lt;code&gt;buyer/mandate/policy.ts&lt;/code&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Three conditions do the work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The transaction must go to the GatewayWallet address.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;depositor&lt;/code&gt; argument must be this agent, so the org wallet cannot fund some other address inside its cap.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;value&lt;/code&gt; must be at or below the cap, written as hex USDC atomic units and rounded down, because rounding a ceiling up authorizes more than the operators approved.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Two quorums, different purposes
&lt;/h2&gt;

&lt;p&gt;A single quorum cannot express the control we wanted. If the wallet needed 2-of-N, funding the agent would need a meeting. If the policy needed 1-of-N, one compromised operator key could raise the cap and then spend against it.&lt;/p&gt;

&lt;p&gt;So the org wallet and the policy have different owners:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Quorum&lt;/th&gt;
&lt;th&gt;Threshold&lt;/th&gt;
&lt;th&gt;Owns&lt;/th&gt;
&lt;th&gt;So this needs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;operations&lt;/td&gt;
&lt;td&gt;1 of 2&lt;/td&gt;
&lt;td&gt;the org wallet&lt;/td&gt;
&lt;td&gt;any one operator, for routine funding&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;board&lt;/td&gt;
&lt;td&gt;2 of 2&lt;/td&gt;
&lt;td&gt;the mandate policy&lt;/td&gt;
&lt;td&gt;both operators, to widen what the agent may spend&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The setup script creates both quorums from the same two operators and hands each one a different resource:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ops&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;createKeyQuorum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;privy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;displayName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Turnstile operations'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;members&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;operators&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;threshold&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;createKeyQuorum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;privy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;displayName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Turnstile board'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;members&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;operators&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;threshold&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;policy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;createMandatePolicy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;privy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;mandate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;agentAddress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ownerQuorumId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;createOrgWallet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;privy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ownerQuorumId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ops&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;policyId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;policy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;displayName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Turnstile buyer org'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;From &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/scripts/privy-org-setup.ts" rel="noopener noreferrer"&gt;&lt;code&gt;scripts/privy-org-setup.ts&lt;/code&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The wallet is created with its owner and policy already set. A wallet created bare and patched later has no owner and no policy for a moment, and we did not want that moment to exist on something holding a treasury. &lt;code&gt;createKeyQuorum&lt;/code&gt; also refuses a threshold above the member count, because that quorum could never approve anything, and you only find out when you need it.&lt;/p&gt;

&lt;p&gt;Every request to change something a quorum owns needs two kinds of proof. Our app secret proves the request comes from Turnstile. The operators' signatures prove who approved it. Each signature covers that exact request, so it cannot be reused to approve a different one. Stealing the app secret gets an attacker the first proof, never the second, so it cannot raise the cap. The two-person rule is enforced by Privy, not by an approval screen in our app that an attacker could go around by calling the API directly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Feog6iaxtajvpyazc3wfo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Feog6iaxtajvpyazc3wfo.png" alt="Turnstile's mandate page, read live from Privy: a $1 spend cap, $0.10 per query, two rails, and the org wallet, operations quorum, board quorum, policy and allowlist behind them" width="800" height="689"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Refusing invalid operations
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;npm run privy:mandate&lt;/code&gt; plays the whole story against the live API. This is the part of the transcript that matters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3 &amp;amp; 4. THE ORG WALLET FUNDS THE AGENT: PRIVY DECIDES, NOT US
fund $0.25, at the cap, alice approves        SIGNED  0x02f8d2834cef5280830f4240…
fund $1, over the cap, alice approves         REFUSED 400 policy_violation
fund $0.25, nobody approves                   REFUSED 401 Missing `privy-authorization-signature` header

5. RAISING THE CAP NEEDS A QUORUM
alice (CFO) proposes raising the cap $0.25 → $1

alice alone      REFUSED 401 Number of signatures in `privy-authorization-signature` header
                 does not match the wallet's authorization threshold.

bob (Head of Research) approves.

alice + bob      RAISED → Turnstile mandate, $1 cap
fund $1, the same request as beat 4           SIGNED  0x02f8d2834cef5280830f4240…
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;From &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/docs/privy-mandate.md" rel="noopener noreferrer"&gt;&lt;code&gt;docs/privy-mandate.md&lt;/code&gt;&lt;/a&gt;, punctuation lightly edited&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The three failures are different, and we keep them apart in code. &lt;code&gt;400 policy_violation&lt;/code&gt; is the organization saying no. &lt;code&gt;401&lt;/code&gt; with a missing header means nobody asked. &lt;code&gt;401&lt;/code&gt; with a threshold mismatch means someone asked and not enough people agreed. The error text says "wallet's" even though the resource being patched is a policy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3uz2vtn6m99uzmlsi9jd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3uz2vtn6m99uzmlsi9jd.png" alt="The cap raise with one signature, refused by Privy with a 401: the board quorum needs two signatures and the request carried one" width="800" height="145"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The raise itself is an ordinary &lt;code&gt;PATCH /v1/policies/{id}&lt;/code&gt; with new rules. &lt;code&gt;raiseSpendCap&lt;/code&gt; has no force flag and no admin override, and could not have a useful one: the threshold check runs on Privy's side, so an override in our code would be a 401 with extra steps. It also refuses to lower a cap. Lowering carries different risk and should not slip through the raise path.&lt;/p&gt;

&lt;p&gt;Then the money moved. The org wallet signed &lt;code&gt;approve&lt;/code&gt; and &lt;code&gt;depositFor&lt;/code&gt; with one operator's approval, inside the policy, and we broadcast both ourselves. Privy does not route RPC for Arc testnet, and it doesn't need to: &lt;code&gt;eth_signTransaction&lt;/code&gt; only needs a &lt;code&gt;chain_id&lt;/code&gt; to produce an EIP-155 signature. Both transactions are on &lt;a href="https://testnet.arcscan.app/address/0x3De96375140717193f52c220Df5Ec460971cbE84" rel="noopener noreferrer"&gt;ArcScan&lt;/a&gt;, sent from the org wallet four seconds apart. The agent's Gateway balance went from 0.1055 to 0.3555 USDC, and its nonce stayed at 0.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who holds the operator keys
&lt;/h2&gt;

&lt;p&gt;Operator keys are P-256 keys, the kind Privy accepts in a quorum. On &lt;code&gt;/mandate/new&lt;/code&gt; the browser generates them and sends us only the public half, so our database, logs and environment never hold anyone's approval key.&lt;/p&gt;

&lt;p&gt;That protection is not perfect. The private key is shown on the page and the operator copies it into a &lt;code&gt;.env&lt;/code&gt; file, so it ends up as plain text on their laptop. And our server serves the page's code: a compromised server could ship a version that copies the key as it is made.&lt;/p&gt;

&lt;p&gt;If we built it again, we would not hand out raw keys. Privy accepts two better kinds of quorum member:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A &lt;strong&gt;passkey&lt;/strong&gt; is a P-256 key held in the device's secure hardware, so it cannot be exported or copied into a file.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Privy user&lt;/strong&gt; is a person who logs in to Privy. That is the route for a wallet such as MetaMask: its keys are on a different curve, so it cannot be a member directly.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Multisigs, session keys and x402 buyers
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Multisig and threshold approval.&lt;/strong&gt; A key quorum is an m-of-n approval, like a Safe. The difference is where it runs: a Safe checks signatures on chain and pays gas to do it. A Privy quorum is checked by Privy's API and enclave before a signature exists, so nothing reaches the chain unless the policy and threshold both pass. You gain speed and any-chain signing, but you trust Privy's infrastructure instead of a contract you can read. For an org wallet that funds an agent a few times a day, that trade is fine. For a cold treasury we would still want something on chain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Account abstraction session keys.&lt;/strong&gt; A session key is a scoped signer on a smart account (targets, a spend limit, an expiry) enforced by a validator module. Same idea of bounded delegation, but the limit lives next to the account. Our setup has no smart account: the agent is a plain EOA that never transacts, and the limit sits one level up, on the tap that fills its balance. What session keys do not give you out of the box is the asymmetry: one approval to operate, two to change the rules.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;x402 buyers.&lt;/strong&gt; An x402 buyer is where this matters most, because the agent reads a &lt;code&gt;402&lt;/code&gt; challenge and decides to sign a payment on its own. Turnstile enforces the mandate twice. First, the agent's own code checks each offer against the seller allowlist, the per-query ceiling and what is left of the cap, and refuses before signing. Then Privy refuses to hand the agent money beyond the cap at all. The first check is the agent being well behaved. The second holds even when it is not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rough edges and gotchas
&lt;/h2&gt;

&lt;p&gt;Five come from Turnstile itself.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A catch-all &lt;code&gt;{ method: '*', action: 'DENY' }&lt;/code&gt; blocks everything&lt;/strong&gt;, including requests an earlier ALLOW matched. Privy's docs do say "if any rule evaluates to a DENY action, the policy engine will DENY the request", but writing rules as a list invites the firewall habit of a final deny. Privy is already deny-by-default, so leave it out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Address comparisons are case-sensitive.&lt;/strong&gt; A classic one. Privy stores your rule's address checksummed, and a lowercase &lt;code&gt;to&lt;/code&gt; then fails to match. Run every address through &lt;code&gt;getAddress()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;policy_violation&lt;/code&gt; has no detail.&lt;/strong&gt; It does not name the rule or condition that denied, so we debugged a three-condition rule by bisecting it into new policies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gas fields reject decimal strings.&lt;/strong&gt; &lt;code&gt;gas_limit&lt;/code&gt; and the fee fields take a JSON number or a &lt;code&gt;0x&lt;/code&gt; string. &lt;code&gt;bigint.toString()&lt;/code&gt; produces exactly the rejected form, and Arc fee values overflow a safe integer, so we send hex everywhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;GET /v1/policies&lt;/code&gt; and &lt;code&gt;GET /v1/key_quorums&lt;/code&gt; return 405&lt;/strong&gt;, so an interrupted setup leaves orphans you cannot list.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Turnstile's Privy cap is &lt;strong&gt;per deposit&lt;/strong&gt;, not cumulative. The running total is tracked by the agent's own ledger. We reused the same Privy app in our next project, Sente, where you hire an AI agent to trade on Monad, and tried to close that gap with a stateful policy. That work added three more findings.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Rolling-cap aggregation is enforced late.&lt;/strong&gt; A second sign request straight after the first overshot the cap. The same request was refused five seconds later. Privy's docs are candid about this: aggregation values are "updated after a request is successfully signed, not before", and stateful policies are meant as "disaster prevention" rather than strict real-time enforcement. So keep a per-transaction cap below the aggregate and space your writes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A sign request right after a policy PATCH can still run under the old rule.&lt;/strong&gt; In that run the new rule took effect roughly 0.85 to 1.3 seconds after the PATCH returned. We would not promise instant revocation. Poll with a sign-only probe until two answers in a row agree.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chain ids are encoded differently in different places.&lt;/strong&gt; The transaction &lt;code&gt;chain_id&lt;/code&gt; accepted hex. The typed-data domain &lt;code&gt;chainId&lt;/code&gt; condition and the timestamp needed decimal. Typed-data requests carry no transaction chain id at all, so the chain has to be pinned through the EIP-712 domain.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Turnstile repository&lt;/a&gt;: all code excerpts; &lt;code&gt;docs/privy-mandate.md&lt;/code&gt; holds the live transcript and rough edges, &lt;code&gt;docs/EVIDENCE.md&lt;/code&gt; the evidence table.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://testnet.arcscan.app/address/0x3De96375140717193f52c220Df5Ec460971cbE84" rel="noopener noreferrer"&gt;ArcScan: org wallet&lt;/a&gt;: the Privy server wallet on Arc testnet.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://testnet.arcscan.app/tx/0x3c526daf25216ac831ba21f828458e4bdd7562227b012b399b3e05f0869320de" rel="noopener noreferrer"&gt;ArcScan: approve tx&lt;/a&gt;: &lt;code&gt;approve&lt;/code&gt; from the org wallet, success.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://testnet.arcscan.app/tx/0x681ba1cdbe5b46c6dcd6a7f906265b678099c501e425d62b114793d65c297ec3" rel="noopener noreferrer"&gt;ArcScan: depositFor tx&lt;/a&gt;: &lt;code&gt;depositFor&lt;/code&gt; from the org wallet to the GatewayWallet, success.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.privy.io/controls/key-quorum/overview.md" rel="noopener noreferrer"&gt;Privy: Key quorums overview&lt;/a&gt;: m-of-n quorums that own wallets and policies.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.privy.io/controls/key-quorum/sign.md" rel="noopener noreferrer"&gt;Privy: Signing with a key quorum&lt;/a&gt;: multiple signatures as a comma-delimited &lt;code&gt;privy-authorization-signature&lt;/code&gt; header.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.privy.io/controls/authorization-keys/using-owners/sign/overview.md" rel="noopener noreferrer"&gt;Privy: Signing requests overview&lt;/a&gt;: the signed payload fields; GET requests are not signed.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.privy.io/controls/authorization-keys/using-owners/sign/signing-on-the-server.md" rel="noopener noreferrer"&gt;Privy: Signing on the server&lt;/a&gt;: ECDSA P-256 signatures, base64 encoded.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.privy.io/controls/authorization-keys/owners/overview.md" rel="noopener noreferrer"&gt;Privy: Owners&lt;/a&gt;: users, authorization keys or key quorums as owners with sole authority to modify wallets and policies.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.privy.io/controls/policies/overview.md" rel="noopener noreferrer"&gt;Privy: Policies overview&lt;/a&gt;: deny-by-default, DENY precedence, enforcement in the enclave before signing.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.privy.io/controls/policies/update-a-policy.md" rel="noopener noreferrer"&gt;Privy: Update a policy&lt;/a&gt;: &lt;code&gt;PATCH /v1/policies/&amp;lt;id&amp;gt;&lt;/code&gt;, owner signature required.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.privy.io/controls/policies/stateful-policies.md" rel="noopener noreferrer"&gt;Privy: Stateful policies&lt;/a&gt;: rolling-window aggregations, updated after signing, framed as disaster prevention.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.privy.io/wallets/using-wallets/ethereum/sign-a-transaction.md" rel="noopener noreferrer"&gt;Privy: Sign a transaction&lt;/a&gt;: &lt;code&gt;eth_signTransaction&lt;/code&gt; signs without broadcasting.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.privy.io/controls/authorization-keys/owners/types.md" rel="noopener noreferrer"&gt;Privy: Types of owners and signers&lt;/a&gt;: users, P-256 authorization keys (including passkeys) and key quorums mixing both.&lt;/li&gt;
&lt;li&gt;Sente: the rolling-cap, PATCH timing and chain-id encoding findings (&lt;a href="https://github.com/IpastorSan/sente-monad-hackathon" rel="noopener noreferrer"&gt;repo&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Next in the series:&lt;/strong&gt; &lt;a href="https://ignaciopastorsanchez.com/blog/chainlink-cre-confidential-workflows-sell-the-answer" rel="noopener noreferrer"&gt;Sell the answer, keep the method: Chainlink CRE Confidential Workflows&lt;/a&gt;, part 8 of 9.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>web3</category>
      <category>security</category>
    </item>
    <item>
      <title>Three listings per human: capping an open agent registry with World ID Selfie Check</title>
      <dc:creator>Ignacio Pastor Sánchez</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:36:41 +0000</pubDate>
      <link>https://dev.to/ignacio_pastor/three-listings-per-human-capping-an-open-agent-registry-with-world-id-selfie-check-23f2</link>
      <guid>https://dev.to/ignacio_pastor/three-listings-per-human-capping-an-open-agent-registry-with-world-id-selfie-check-23f2</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 6 of 9 in the &lt;a href="https://ignaciopastorsanchez.com/blog/series/turnstile" rel="noopener noreferrer"&gt;Turnstile series&lt;/a&gt;: building a paid lane for onchain data agents.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;Turnstile is a market where AI agents find sellers through the ERC-8004 registry and pay them per query. Anyone can register an agent and publish a price. That is the point, but also the problem: one person with a script can register two hundred subnames and bury every honest seller in the ranking.&lt;/p&gt;

&lt;p&gt;We added proof of personhood with World ID. It answers one question: is the user trying to create a listing an actual human? We need to know so we can cap how much of the registry one person can hold. &lt;strong&gt;Three listings per human.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Five pieces make it work.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;World ID Selfie Check&lt;/strong&gt;, a medium-assurance credential: a phone camera liveness check plus a comparison against faces already enrolled, not an Orb. Enough to make farming expensive.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IDKit v4&lt;/strong&gt;, World's SDK, runs the Selfie Check in the browser. The server signs the request and verifies the proof; the browser is trusted with nothing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The nullifier&lt;/strong&gt;, a stable pseudonym per app and per action. We count listings against it and &lt;strong&gt;never return it to the browser&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The signal&lt;/strong&gt;, a string the proof is bound to. We use the listing's name, so a proof made for one listing can't be replayed to claim another.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reservations.&lt;/strong&gt; A verified subname under &lt;code&gt;turnstile.eth&lt;/code&gt; counts against the cap before it is registered as an agent, so verifying names first and registering them later does not dodge it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The code is at &lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;github.com/IpastorSan/turnstile&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why an open registry needs a Sybil control
&lt;/h2&gt;

&lt;p&gt;ERC-8004 gives agents a portable identity: an ERC-721 token in an Identity Registry, addressed by the registry's location, &lt;code&gt;{namespace}:{chainId}:{identityRegistry}&lt;/code&gt; (e.g. &lt;code&gt;eip155:11155111:0x8004A818…BD9e&lt;/code&gt;, Sepolia plus the registry's contract address), and a token id. Turnstile reads that registry (the indexing side is in &lt;a href="https://ignaciopastorsanchez.com/blog/erc8004-agent-discovery-substreams" rel="noopener noreferrer"&gt;ERC-8004 agent discovery with Substreams&lt;/a&gt;). Every Turnstile seller is also an ENS subname under &lt;code&gt;turnstile.eth&lt;/code&gt; carrying its offer records (&lt;a href="https://ignaciopastorsanchez.com/blog/ensv2-agent-offer-records-hot-cold-keys" rel="noopener noreferrer"&gt;ENSv2 agent offer records&lt;/a&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart LR
  subgraph S["ERC-8004 on Sepolia"]
    IR["Identity Registry&amp;lt;br/&amp;gt;ERC-721 at 0x8004A818…BD9e"] --&amp;gt; A["agent 10127&amp;lt;br/&amp;gt;eip155:11155111:0x8004A818…BD9e / 10127"]
  end
  subgraph E["ENS"]
    N["liquidity.turnstile.eth&amp;lt;br/&amp;gt;offer records: price, rails, payout"]
  end
  A --&amp;gt;|"agentURI"| N
  N -.-&amp;gt;|"agent-registration record"| A
  T["Turnstile market"] --&amp;gt;|"indexes"| IR
  T --&amp;gt;|"reads offers"| N&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;Nothing in that picture says who is behind an agent. Registering one costs a transaction and asks for no proof of who you are, so one person can register as many as they like. &lt;/p&gt;

&lt;p&gt;It's by design, and &lt;a href="https://eips.ethereum.org/EIPS/eip-8004" rel="noopener noreferrer"&gt;ERC-8004&lt;/a&gt; says so. Its security section admits that Sybil attacks are possible and can inflate the reputation of fake agents, but it leaves the answer to the ecosystem: reputation systems that filter agents through trusted reviewers. &lt;/p&gt;

&lt;p&gt;The classic result is still Douceur's 2002 paper, &lt;a href="https://www.microsoft.com/en-us/research/publication/the-sybil-attack/" rel="noopener noreferrer"&gt;"The Sybil Attack"&lt;/a&gt;. Without a trusted agency certifying identities, one entity can pretend to be many, except under unrealistic assumptions about resource consumption. Basically, &lt;strong&gt;a sybil attack is viable if creating multiple identities in a given system is cheap enough and no one is checking&lt;/strong&gt;. There are four usual ways around it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Resource cost&lt;/strong&gt;: stake, fees, proof of work. Farming gets expensive, but a funded attacker can still bypass it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Social graph or web of trust&lt;/strong&gt;: works once you have a graph. A new market has none.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reputation over time&lt;/strong&gt;: the ERC-8004 answer. Slow, and it needs honest raters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proof of personhood&lt;/strong&gt;: bind an identity to a unique human and let the application set the policy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We picked the last one. It does not replace the others, but it is the only one that works on a market with no history.&lt;/p&gt;

&lt;p&gt;In World ID, the person doesn't hand us an identity. After the check, the World App on their phone produces a proof: a &lt;strong&gt;zero-knowledge proof that says "a verified human approved this listing" without saying which human&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;It carries two things we use. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The nullifier: a pseudonym that is the same every time this person verifies with us. &lt;/li&gt;
&lt;li&gt;The signal: the listing the proof was made for. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The nullifier is how we count how many listings that human already holds. The signal makes sure the proof is spent on the listing it was made for, and no other.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why three, and why Selfie Check is enough
&lt;/h2&gt;

&lt;p&gt;A real operator sells more than one thing; even our own liquidity analyst and a depth analyst are different services at different prices. &lt;strong&gt;We limit the maximum listings a single person can publish to three&lt;/strong&gt;, this cap only exists to make farming expensive. Three is an arbitrary decision and could be expanded.&lt;/p&gt;

&lt;p&gt;For Turnstile we chose World's Selfie Check because it gave us the best balance of ease of implementation, user experience and security: anyone with the World App can do it from their phone, with no Orb visit and no passport.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://world.org" rel="noopener noreferrer"&gt;World&lt;/a&gt; ranks its credentials by assurance: how sure you can be that each verified account is a different real person. The top level is the Orb, World's iris-scanning device, which checks that nobody has ever verified twice. Selfie Check is &lt;strong&gt;medium-assurance&lt;/strong&gt;. It runs on the phone camera and checks two things. Liveness: a real person is in front of the camera, not a photo or an injected video. Facial similarity: at enrollment, the new face is compared privately with the faces already enrolled, and the response carries a &lt;code&gt;sybil_score&lt;/code&gt; saying how many more matches turned up than chance would explain. World has since renamed the credential Proof of Presence. &lt;/p&gt;

&lt;p&gt;The verification lasts 90 days without use, after which the person takes the selfie again.&lt;/p&gt;

&lt;p&gt;Medium assurance is enough for us. We are not running an airdrop where one extra identity is worth money. What we need is for farming two hundred listings to cost two hundred faces instead of two hundred transactions.&lt;/p&gt;

&lt;p&gt;One Developer Portal setting matters more than it looks: &lt;code&gt;max_verifications&lt;/code&gt; on the action. Its default is 1, so World refuses a person's &lt;em&gt;second&lt;/em&gt; verification. At that default the limit a user hits is World's, and our own "three, then refuse the fourth" never runs. We created the action with &lt;code&gt;0&lt;/code&gt; (unlimited), so World proves personhood and Turnstile sets the policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  The flow: sign on the server, verify on the server
&lt;/h2&gt;

&lt;p&gt;The IDKit v4 integration has three hops.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The browser asks &lt;code&gt;/api/world/context&lt;/code&gt; for a signed RP context. In World's vocabulary the RP, or relying party, is the app asking for the proof: Turnstile. It is registered in World's Developer Portal under an &lt;code&gt;rp_id&lt;/code&gt; and holds a signing key. The RP context is the request for a proof, signed with that key, so World knows it really comes from Turnstile. The signing key never leaves the server.&lt;/li&gt;
&lt;li&gt;The browser mounts &lt;code&gt;IDKitRequestWidget&lt;/code&gt; with &lt;code&gt;selfieCheckLegacy({ signal: listing })&lt;/code&gt; and &lt;code&gt;allow_legacy_proofs&lt;/code&gt;. The "legacy" is World ID 3.0: when we built this, Selfie Check only worked there. World has since added a &lt;code&gt;selfieCheck&lt;/code&gt; preset for World ID 4.0.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;handleVerify&lt;/code&gt; posts the IDKit result, untouched, to &lt;code&gt;/api/world/verify&lt;/code&gt;. The server forwards it to the Developer Portal, takes the nullifier from the proof the portal has &lt;em&gt;verified&lt;/em&gt;, and applies the cap.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Verification is a plain POST to &lt;code&gt;https://developer.world.org/api/v4/verify/{rp_id}&lt;/code&gt;, body forwarded as-is. The detail we care most about is what happens when the portal says yes and we cannot find a nullifier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;nullifier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;nullifierFrom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="nf"&gt;nullifierFrom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;idkitResult&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;nullifier&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Without a nullifier there is nothing to count listings against, so a&lt;/span&gt;
  &lt;span class="c1"&gt;// "success" here would let one human verify repeatedly and hold unlimited listings.&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'the portal accepted the proof but returned no nullifier, so it cannot be counted against a person'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;proof&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;nullifier&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/identity/world.ts" rel="noopener noreferrer"&gt;identity/world.ts&lt;/a&gt; (trimmed)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Why refuse a proof World just accepted? Because &lt;strong&gt;the three listings cap runs on the nullifier&lt;/strong&gt;. It is the one value that stays the same every time the same person verifies, so it is how we count how many listings that person already holds. A "yes" without a nullifier says a human is there but not which one, so we can't add the listing to anyone's count. Accept it and the same person could verify again and again, each time uncounted, and hold as many listings as they like. So no nullifier means no listing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The nullifier: a pseudonym you keep to yourself
&lt;/h2&gt;

&lt;p&gt;World defines the nullifier as a unique identifier for one user, one app and one action. Same human, same action, same app: same value. A different app gives a different one, so activity cannot be linked across apps.&lt;/p&gt;

&lt;p&gt;We can use this to count rows sharing a nullifier. We know which listings belong to the same person, even if we cannot tell who that person is.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The action string needs to be immutable.&lt;/strong&gt; Nullifiers are scoped to it, so renaming &lt;code&gt;turnstile-operator&lt;/code&gt; would silently reset every human's count. It is a pinned constant, not a parameter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The nullifier stays on the server.&lt;/strong&gt; It is stable. If &lt;code&gt;/api/world/verify&lt;/code&gt; returned it, anyone watching responses could correlate listings back to one person outside our store, which undoes the unlinkability World designed in. The route returns the tally (&lt;code&gt;used&lt;/code&gt;, &lt;code&gt;limit&lt;/code&gt;, &lt;code&gt;remaining&lt;/code&gt;) and the listings held, never the value.&lt;/p&gt;

&lt;p&gt;The verify route, trimmed to the order of operations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;bound&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;checkSignal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;proof&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;bound&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'signal_mismatch'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;bound&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reason&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;resolved&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;canonicalAgentUid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;            &lt;span class="c1"&gt;// a registered name becomes its agent uid, an unregistered one a reservation;&lt;/span&gt;
                                                            &lt;span class="c1"&gt;// the key comes from the store, never the client&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;resolved&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;resolved&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;resolved&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reason&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;listing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;resolved&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;resolved&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ensName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;resolved&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ensName&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;outcome&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;verifyProof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;worldConfigFromEnv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;proof&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;outcome&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verified&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;outcome&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reason&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;nullifier&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;outcome&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;proof&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                        &lt;span class="c1"&gt;// from the verified proof, never a field the browser fills in&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;allowance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;mayClaim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nullifier&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;listing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;allowance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;recordVerification&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;agentUid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;listing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nullifier&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'rejected'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;proofRef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;allowance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&gt;'refused'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verified&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;allowance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;allowance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;allowance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;limit&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;409&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;recordVerification&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;agentUid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;listing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nullifier&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'verified'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// response: listing, used, limit, remaining. Never the nullifier.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/web/app/api/world/verify/route.ts" rel="noopener noreferrer"&gt;web/app/api/world/verify/route.ts&lt;/a&gt; (trimmed)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The nullifier comes from a proof World has verified, never from a field the browser fills in on its own. The browser writes the request, so a nullifier taken from it unchecked could be anything: a fresh one each time to reset the count, or someone else's to fill up their allowance. When the portal's response lacks one, &lt;code&gt;verifyProof&lt;/code&gt; falls back to the nullifier inside the IDKit result, which is safe only because the portal has just checked that proof, nullifier included.&lt;/p&gt;

&lt;h2&gt;
  
  
  The signal: which listing is this proof for?
&lt;/h2&gt;

&lt;p&gt;A signal is any string the app gives IDKit before the user proves; the proof is computed over its hash, so it is only valid for that string. Ours is the listing.&lt;/p&gt;

&lt;p&gt;The Developer Portal checks a proof against the &lt;code&gt;signal_hash&lt;/code&gt; inside the payload. It will happily verify a proof made for a different listing. So before anything is stored, &lt;code&gt;checkSignal&lt;/code&gt; compares every &lt;code&gt;signal_hash&lt;/code&gt; in the IDKit responses with &lt;code&gt;hashSignal(listing)&lt;/code&gt;, the exact string the widget signed. A mismatch is refused as &lt;code&gt;signal_mismatch&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There is one soft spot. IDKit documents &lt;code&gt;signal_hash&lt;/code&gt; as optional, and we have not yet confirmed from a real Selfie Check payload that it is always there. So a payload with no &lt;code&gt;signal_hash&lt;/code&gt; passes as &lt;code&gt;checked: false&lt;/code&gt; instead of being refused. We left it that way because the cost is bounded: under one action, every listing a human verifies shares their nullifier, so a replayed proof can only spend its own human's allowance.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cap, including reservations
&lt;/h2&gt;

&lt;p&gt;A seller doesn't need a registered agent to verify. On &lt;code&gt;/onboard&lt;/code&gt; they pick a name under &lt;code&gt;turnstile.eth&lt;/code&gt;, say &lt;code&gt;depth.turnstile.eth&lt;/code&gt;, and can take the selfie before that name is an ERC-8004 agent. A verified name with no agent behind it yet is a &lt;strong&gt;reservation&lt;/strong&gt;: we store the verification under the ENS name, and when the agent is registered the row moves to its agent uid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F67dvec395d4zye8bcf33.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F67dvec395d4zye8bcf33.png" alt="The Verify a listing block on /onboard: choose a registered agent or a reserved name, then verify it with World Selfie Check" width="800" height="269"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Reservations count against the same three listings. If they didn't, the cap would be easy to dodge: verify two hundred names while none of them is an agent yet, so each one counts as zero, then register them all. Counting reservations means the fourth verification is refused before anything is registered.&lt;/p&gt;

&lt;p&gt;Every new verification goes through &lt;code&gt;mayClaim&lt;/code&gt;, which decides whether this human may take this listing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;mayClaim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;DatabaseSync&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nullifier&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;agentUid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ListingAllowance&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;standing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;standingFor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nullifier&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;standing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;agents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;agentUid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;standing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;standing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;allowance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;remaining&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;standing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;allowance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remaining&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;existing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;verificationFor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;agentUid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;existing&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'verified'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;existing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nullifier&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="n"&gt;nullifier&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'listing_held_by_another_human'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;standing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;allowance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// listing_limit_reached once used &amp;gt;= 3&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/identity/store.ts" rel="noopener noreferrer"&gt;identity/store.ts&lt;/a&gt; (trimmed)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It answers three cases, in order:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A listing you already hold:&lt;/strong&gt; allowed, and it uses no new slot, so re-verifying a listing costs nothing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A listing another human holds:&lt;/strong&gt; refused, so nobody can take over someone else's listing by verifying it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Anything else:&lt;/strong&gt; allowed while you hold fewer than three, refused with &lt;code&gt;listing_limit_reached&lt;/code&gt; after that.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Only &lt;code&gt;verified&lt;/code&gt; rows count. A rejected row records that somebody tried, and counting it would let a failed attempt eat someone else's allowance.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it buys
&lt;/h2&gt;

&lt;p&gt;The registry is still open. Anyone can register an agent and publish a price, and nothing here asks who they are. What changed is the price of flooding it: farming two hundred listings used to cost two hundred transactions, and now it costs two hundred faces. Three listings per human, counted against a pseudonym we never show, is a policy an open market can live with on day one, before it has any history to rank sellers by.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.world.org/world-id" rel="noopener noreferrer"&gt;World ID overview&lt;/a&gt;: World ID as proof of human and uniqueness; the three credential types (Proof of Human via Orb, Document, Selfie Check).&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.world.org/world-id/credentials/11" rel="noopener noreferrer"&gt;Proof of Presence, formerly Selfie Check&lt;/a&gt;: medium assurance, liveness plus facial similarity against enrolled faces, &lt;code&gt;sybil_score&lt;/code&gt; as a risk signal, no strict one-person-one-account guarantee, 90-day inactivity window.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.world.org/world-id/idkit/integrate" rel="noopener noreferrer"&gt;IDKit integrate guide&lt;/a&gt;: server-side &lt;code&gt;signRequest&lt;/code&gt;, never expose the signing key, &lt;code&gt;POST https://developer.world.org/api/v4/verify/{rp_id}&lt;/code&gt;, forward the payload as-is, nullifier checks on the backend.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.world.org/world-id/idkit/credentials" rel="noopener noreferrer"&gt;IDKit credentials and presets&lt;/a&gt;: &lt;code&gt;selfieCheckLegacy()&lt;/code&gt; on World ID 3.0 and the newer &lt;code&gt;selfieCheck&lt;/code&gt; for 4.0, &lt;code&gt;signal&lt;/code&gt; binding, &lt;code&gt;allow_legacy_proofs&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.world.org/world-id/concepts" rel="noopener noreferrer"&gt;World ID concepts&lt;/a&gt;: nullifier as unique per user, app and action; same value on repeat; unlinkable across apps.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/worldcoin/idkit" rel="noopener noreferrer"&gt;worldcoin/idkit on GitHub&lt;/a&gt;: the IDKit SDK repo that &lt;code&gt;@worldcoin/idkit&lt;/code&gt; 4.2.3 and &lt;code&gt;@worldcoin/idkit-core&lt;/code&gt; 4.2.4 point to.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://eips.ethereum.org/EIPS/eip-8004" rel="noopener noreferrer"&gt;ERC-8004: Trustless Agents&lt;/a&gt;: Identity, Reputation and Validation registries; &lt;code&gt;agentRegistry&lt;/code&gt; format; Sybil attacks acknowledged and left to reputation filtering.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.microsoft.com/en-us/research/publication/the-sybil-attack/" rel="noopener noreferrer"&gt;Douceur, "The Sybil Attack" (IPTPS 2002)&lt;/a&gt;: without a trusted certifying agency, Sybil attacks stay feasible.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Turnstile repository&lt;/a&gt;: &lt;code&gt;identity/&lt;/code&gt;, the World routes.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Next in the series:&lt;/strong&gt; &lt;a href="https://ignaciopastorsanchez.com/blog/privy-spending-mandates-key-quorums" rel="noopener noreferrer"&gt;Spending mandates for agents: the key that spends can never raise its own limit&lt;/a&gt;, part 7 of 9.&lt;/p&gt;

</description>
      <category>web3</category>
      <category>ai</category>
      <category>agents</category>
      <category>security</category>
    </item>
    <item>
      <title>The offer is the name: ENSv2 records and a key split the chain enforces</title>
      <dc:creator>Ignacio Pastor Sánchez</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:36:32 +0000</pubDate>
      <link>https://dev.to/ignacio_pastor/the-offer-is-the-name-ensv2-records-and-a-key-split-the-chain-enforces-3dch</link>
      <guid>https://dev.to/ignacio_pastor/the-offer-is-the-name-ensv2-records-and-a-key-split-the-chain-enforces-3dch</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 5 of 9 in the &lt;a href="https://ignaciopastorsanchez.com/blog/series/turnstile" rel="noopener noreferrer"&gt;Turnstile series&lt;/a&gt;: building a paid lane for onchain data agents.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;We built &lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Turnstile&lt;/a&gt;, a marketplace where AI agents sell answers and other agents pay for them. One seller, &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt;, lives on Sepolia. We wanted the things a buyer needs before paying (price, accepted rails, where to connect, where money lands) to live in one place nobody could quietly edit behind our backs. That place ended up being the ENS name itself.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Our own registry, plugged into ENS.&lt;/strong&gt; In ENSv2 every name can have a registry for the names under it. &lt;code&gt;turnstile.eth&lt;/code&gt; points to ours, so any ENS client resolves &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt; as usual. The registry, which records who owns each name, is an unmodified copy of ENS's own &lt;code&gt;UserRegistry&lt;/code&gt;. The registrar, which sells the names, is ours: ENS ships no registrar for subnames, so we wrote one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The resolver record is the offer.&lt;/strong&gt; Standard keys first: &lt;a href="https://docs.ens.domains/ensip/26" rel="noopener noreferrer"&gt;ENSIP-26&lt;/a&gt; &lt;code&gt;agent-context&lt;/code&gt; and &lt;code&gt;agent-endpoint[mcp]&lt;/code&gt;, &lt;a href="https://docs.ens.domains/ensip/25" rel="noopener noreferrer"&gt;ENSIP-25&lt;/a&gt; &lt;code&gt;agent-registration[...]&lt;/code&gt;. Then a few &lt;code&gt;turnstile:&lt;/code&gt; keys for price, ceiling and rails. The payout is the name's plain &lt;code&gt;addr&lt;/code&gt; record.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Two keys, scoped per record.&lt;/strong&gt; With ENSv2 Enhanced Access Control on ENS's &lt;code&gt;PermissionedResolver&lt;/code&gt;, the hot key can write and modify exactly two records: the price and the MCP endpoint. Its &lt;code&gt;setAddr&lt;/code&gt; call to redirect the payout reverts with &lt;code&gt;EACUnauthorizedAccountRoles&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Where the keys live is a separate choice.&lt;/strong&gt; The resolver grants roles to addresses, so the operator role can belong to a hardware wallet, a Safe multisig or a policy-controlled wallet. The last section compares them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  197 agents, no standard place for a price
&lt;/h2&gt;

&lt;p&gt;Turnstile's discovery side indexes &lt;a href="https://eips.ethereum.org/EIPS/eip-8004" rel="noopener noreferrer"&gt;ERC-8004&lt;/a&gt; agent registrations across Base, mainnet and Sepolia (check  &lt;a href="https://ignaciopastorsanchez.com/blog/erc8004-agent-discovery-substreams" rel="noopener noreferrer"&gt;A sample of 197 ERC-8004 agents, and where their prices live&lt;/a&gt; for details). When we measured a sample of 197 registrations, two published a price any buyer's agent could read: ours, and one agent that quotes a price in its x402 response. Another 76, all Virtuals agents, list prices in the &lt;code&gt;jobOfferings&lt;/code&gt; field defined by ACP, Virtuals' Agent Commerce Protocol. Those prices name no currency, so a buyer can't compare them with a dollar price. ERC-8004's registration file has no price field, so there is no standard place to put the number.&lt;/p&gt;

&lt;p&gt;A price is not enough on its own. A buyer's agent is about to send money. It needs to know:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What the service is, and where to connect.&lt;/li&gt;
&lt;li&gt;What it costs and which payment rails the seller accepts.&lt;/li&gt;
&lt;li&gt;Where the money goes.&lt;/li&gt;
&lt;li&gt;That none of those were changed by someone who should not be able to change them.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Point 4 is where a web page or a JSON file falls short. If the offer lives on our server, anyone who compromises our server changes the offer. If it lives in resolver records, the contract decides who may write each record, and anyone can read those permissions onchain. Someone who steals the key we use day to day can change the price and the endpoint, but not where the money goes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: our own registry, plugged into ENS
&lt;/h2&gt;

&lt;p&gt;ENSv2 changes the shape of names. Instead of one big registry, every name can have its own registry, and registries point at their parent. &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt; hangs off this chain on Sepolia:&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
  subgraph ENS["Deployed by ENS"]
    R["RootRegistry&amp;lt;br/&amp;gt;0x11b5…f50c"] --&amp;gt;|"eth"| E["ETHRegistry&amp;lt;br/&amp;gt;0x67b7…4b43"]
  end
  subgraph T["Deployed by us"]
    TR["TurnstileRegistry&amp;lt;br/&amp;gt;unmodified UserRegistry&amp;lt;br/&amp;gt;0x1096…2d24"]
    REG["TurnstileRegistrar&amp;lt;br/&amp;gt;sells and renews names"]
    N["liquidity.turnstile.eth"]
  end
  E --&amp;gt;|"turnstile"| TR
  TR --&amp;gt;|"liquidity"| N
  REG -.-&amp;gt;|"mints into"| TR&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;We did not write a registry. &lt;code&gt;TurnstileRegistry&lt;/code&gt; is a small library that deploys an instance of ENS's own &lt;code&gt;UserRegistry&lt;/code&gt; through ENS's &lt;code&gt;VerifiableFactory&lt;/code&gt;. The reason is verification: &lt;code&gt;VerifiableFactory.verifyContract(proxy)&lt;/code&gt; returns the implementation behind a proxy, so a buyer's agent can confirm the registry (and later the resolver) is unmodified ENS code and not a look-alike that behaves honestly until it doesn't.&lt;/p&gt;

&lt;p&gt;The registrar is the contract that sells names. It sets the price, takes the payment and mints the name in the registry. ENS ships none for subnames: the ENSv2 docs mention a &lt;code&gt;SimpleSubnameRegistrar&lt;/code&gt; to model one on, but &lt;code&gt;ensdomains/contracts-v2&lt;/code&gt; doesn't contain it, and its &lt;code&gt;src/registrar/&lt;/code&gt; only holds the registrars for &lt;code&gt;.eth&lt;/code&gt; names. So we wrote &lt;code&gt;TurnstileRegistrar&lt;/code&gt; from scratch, against ENS's &lt;code&gt;IPermissionedRegistry&lt;/code&gt; interface. It holds exactly two roles, both granted across the whole registry:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/// Mint and renew, and nothing else. In particular **not** `ROLE_UNREGISTER`:
/// the contract that takes buyers' money must not be able to delete the names
/// it sold, and not `ROLE_UPGRADE` or `ROLE_SET_PARENT`, which would let it
/// widen its own authority.
uint256 internal constant REGISTRAR_ROOT_ROLES =
    RegistryRolesLib.ROLE_REGISTRAR | RegistryRolesLib.ROLE_RENEW;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/contracts/src/TurnstileRegistry.sol" rel="noopener noreferrer"&gt;contracts/src/TurnstileRegistry.sol&lt;/a&gt; (comment trimmed)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The registrar can sell and renew names, but it can't delete them or give itself more roles. The hot key in Step 3 follows the same rule: the key that acts every day can't widen its own permissions.&lt;/p&gt;

&lt;p&gt;Plugging it into ENS takes two calls. The registry declares its parent with &lt;code&gt;setParent&lt;/code&gt;, and the owner of &lt;code&gt;turnstile.eth&lt;/code&gt; on ENS's &lt;code&gt;.eth&lt;/code&gt; registry points the label at the registry with &lt;code&gt;setSubregistry&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(IRegistry currentParent, string memory currentLabel) = registry.getParent();
if (address(currentParent) != address(ethRegistry) || /* label differs */) {
    registry.setParent(IRegistry(address(ethRegistry)), cfg.parentLabel);
}

if (address(ethRegistry.getSubregistry(cfg.parentLabel)) == address(registry)) {
    console2.log("subregistry        already linked");
    return;
}
if (parentOwner != cfg.deployer) {
    console2.log("subregistry        SKIPPED - we do not own the parent name");
    return;
}
ethRegistry.setSubregistry(parentTokenId, IRegistry(address(registry)));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/contracts/script/Deploy.s.sol" rel="noopener noreferrer"&gt;contracts/script/Deploy.s.sol&lt;/a&gt; (&lt;code&gt;_linkIntoHierarchy&lt;/code&gt;, trimmed)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Turnstile holds no &lt;code&gt;ROLE_REGISTRAR&lt;/code&gt; on ENS's &lt;code&gt;.eth&lt;/code&gt; registry, so the parent name had to come through the paid &lt;code&gt;ETHRegistrar&lt;/code&gt; flow. Once linked, the address file records &lt;code&gt;linkedIntoHierarchy: true&lt;/code&gt;. Every ENSv2 registry stores its parent and the label it sits under, and &lt;code&gt;getParent()&lt;/code&gt; returns both. Ask our registry and it answers with ENS's &lt;code&gt;.eth&lt;/code&gt; registry and &lt;code&gt;turnstile&lt;/code&gt;. Ask the &lt;code&gt;.eth&lt;/code&gt; registry and it answers with the root registry and &lt;code&gt;eth&lt;/code&gt;. The root has no parent, so the walk stops there, and the labels collected on the way up spell &lt;code&gt;turnstile.eth&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That walk is also how names avoid being hard-coded. A namehash constant goes stale silently the day the registry is re-parented: it still resolves, to a name nobody owns. &lt;code&gt;TurnstileName.sol&lt;/code&gt; derives the full name, its DNS encoding and its namehash by walking &lt;code&gt;getParent()&lt;/code&gt; to the root at run time. The only input is the label, &lt;code&gt;liquidity&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RootRegistry  0x11b5…f50c
  └── "eth" ──&amp;gt; ETHRegistry  0x67b7…4b43        (ENS's)
        └── "turnstile" ──&amp;gt; TurnstileRegistry   (ours, 0x1096…2d24)
              └── "liquidity" ──&amp;gt; liquidity.turnstile.eth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: the resolver record is the offer
&lt;/h2&gt;

&lt;p&gt;The seller name points at an ENS &lt;code&gt;PermissionedResolver&lt;/code&gt;, also deployed through &lt;code&gt;VerifiableFactory&lt;/code&gt;. The operator key writes the offer in two transactions. The first is the resolver's &lt;code&gt;multicall&lt;/code&gt;, which runs a list of calls in one go: here, seven &lt;code&gt;setText(node, key, value)&lt;/code&gt; calls, one for each text record below. &lt;/p&gt;

&lt;p&gt;The second is &lt;code&gt;setAddr(node, 60, payout)&lt;/code&gt;, which sets the payout address. An ENS name can store a different address for each chain, and each chain has a number (&lt;a href="https://github.com/satoshilabs/slips/blob/master/slip-0044.md" rel="noopener noreferrer"&gt;SLIP-44&lt;/a&gt;). The &lt;code&gt;60&lt;/code&gt; says the address is for Ethereum.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Key&lt;/th&gt;
&lt;th&gt;Standard&lt;/th&gt;
&lt;th&gt;Live value&lt;/th&gt;
&lt;th&gt;Writable by&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;agent-context&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ENSIP-26&lt;/td&gt;
&lt;td&gt;service description&lt;/td&gt;
&lt;td&gt;operator key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;agent-endpoint[mcp]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ENSIP-26&lt;/td&gt;
&lt;td&gt;the seller's MCP URL&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;hot key&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;agent-registration[&amp;lt;registry&amp;gt;][10127]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ENSIP-25&lt;/td&gt;
&lt;td&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;operator key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;turnstile:price&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ours&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0.07&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;hot key&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;turnstile:price-ceiling&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ours&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0.50&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;operator key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;turnstile:rails&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ours&lt;/td&gt;
&lt;td&gt;&lt;code&gt;x402,usdc-arc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;operator key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;turnstile:operator-proof&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ours&lt;/td&gt;
&lt;td&gt;&lt;code&gt;operator-key-role-scoped&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;operator key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;addr(60)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ENSIP-1&lt;/td&gt;
&lt;td&gt;the payout address&lt;/td&gt;
&lt;td&gt;operator key&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;The MCP URL is &lt;code&gt;https://turnstile.moveseventyeight.com/liquidity.turnstile.eth/sse&lt;/code&gt;. The registry in the ENSIP-25 key is the identity registry's ERC-7930 address, &lt;code&gt;0x0001000003aa36a7148004a8…bd9e&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Standard keys come first on purpose. &lt;a href="https://docs.ens.domains/ensip/26" rel="noopener noreferrer"&gt;ENSIP-26&lt;/a&gt; defines &lt;code&gt;agent-context&lt;/code&gt; as a description of the agent and how to interact with it, and &lt;code&gt;agent-endpoint[&amp;lt;protocol&amp;gt;]&lt;/code&gt; as a URL for a given protocol such as MCP or A2A. An agent that has never heard of Turnstile can read those two and know what this is and where to connect.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.ens.domains/ensip/25" rel="noopener noreferrer"&gt;ENSIP-25&lt;/a&gt; handles the link between the name and an &lt;a href="https://eips.ethereum.org/EIPS/eip-8004" rel="noopener noreferrer"&gt;ERC-8004&lt;/a&gt; agent registration. The key is &lt;code&gt;agent-registration[&amp;lt;registry&amp;gt;][&amp;lt;agentId&amp;gt;]&lt;/code&gt;, where &lt;code&gt;&amp;lt;registry&amp;gt;&lt;/code&gt; is the &lt;a href="https://eips.ethereum.org/EIPS/eip-7930" rel="noopener noreferrer"&gt;ERC-7930&lt;/a&gt; interoperable address of the registry. A non-empty value, conventionally &lt;code&gt;1&lt;/code&gt;, is the name owner attesting to that agent. Decoded, ours reads: version 1, chain type &lt;code&gt;eip155&lt;/code&gt;, a 3-byte chain reference &lt;code&gt;0xaa36a7&lt;/code&gt; (11155111, Sepolia), then the 20-byte IdentityRegistry address, agent &lt;code&gt;10127&lt;/code&gt;. The key is long and easy to get wrong. If our encoder made a mistake, the record would still save, and our own reader, using the same encoder, would still find it. Every other ENSIP-25 app would look under the correct key and find nothing. So we test the encoder against the example key in the ENSIP itself.&lt;/p&gt;

&lt;p&gt;The link runs both ways. The name carries the ENSIP-25 record, and on the ERC-8004 side &lt;code&gt;tokenURI(10127)&lt;/code&gt; returns &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt;. Turnstile's seller page marks the link as verified only when both directions agree.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;turnstile:&lt;/code&gt; keys cover what no standard defines yet. &lt;code&gt;turnstile:price&lt;/code&gt; is what one answer costs, in US dollars. &lt;code&gt;turnstile:price-ceiling&lt;/code&gt; is the most the seller may charge for any answer. Only the operator key can change it, so the hot key can reprice freely below it but never above. &lt;code&gt;turnstile:rails&lt;/code&gt; lists the payment rails the seller settles on. &lt;code&gt;x402&lt;/code&gt; covers the rails that take standard x402 payments, Hedera (&lt;a href="https://ignaciopastorsanchez.com/blog/x402-on-hedera-blocky402-paid-http" rel="noopener noreferrer"&gt;x402 on Hedera with Blocky402&lt;/a&gt;) and Base (&lt;a href="https://ignaciopastorsanchez.com/blog/chain-agnostic-x402-seller-payment-rails" rel="noopener noreferrer"&gt;One payment interface, four chains&lt;/a&gt;). &lt;code&gt;usdc-arc&lt;/code&gt; is Circle's rail on Arc (&lt;a href="https://ignaciopastorsanchez.com/blog/gasless-nanopayments-eip3009-circle-gateway-arc" rel="noopener noreferrer"&gt;gasless nanopayments on Arc&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The payout is the name's &lt;code&gt;addr&lt;/code&gt; record and not a &lt;code&gt;turnstile:payout&lt;/code&gt; text key. It is the one field every ENS client already reads as "send funds here".&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: scoping a hot key to two records
&lt;/h2&gt;

&lt;p&gt;A seller can make two kinds of changes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Frequent:&lt;/strong&gt; reprice, move the endpoint when the host changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rare and dangerous:&lt;/strong&gt; change the payout address, raise the price ceiling, rotate the day-to-day key.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If one key does both, a leaked key that reprices can also redirect every payment. So there are two keys. The operator key holds the root roles, which cover every record on every name in the resolver. The hot key runs the frequent changes and nothing else.&lt;/p&gt;

&lt;p&gt;ENSv2's &lt;a href="https://docs.ens.domains/contracts/ensv2/enhanced-access-control" rel="noopener noreferrer"&gt;Enhanced Access Control&lt;/a&gt; does this without us writing an access-control contract. Every permission is a role held on a resource, which is an ID for the thing the role covers. Resource 0 is the root and covers everything in the contract. Each role has an admin role, and only holders of the admin role can grant it. &lt;br&gt;
The &lt;a href="https://docs.ens.domains/contracts/ensv2/permissioned-resolver" rel="noopener noreferrer"&gt;Permissioned Resolver&lt;/a&gt; makes a resource ID for each record by hashing the name together with the record's key, so a role on &lt;code&gt;turnstile:price&lt;/code&gt; for &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt; covers that one record and nothing else. The functions that grant these are &lt;code&gt;authorizeTextRoles&lt;/code&gt;, &lt;code&gt;authorizeDataRoles&lt;/code&gt; and &lt;code&gt;authorizeAddrRoles&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A role can be granted at four levels, depending on whether it targets one name or all of them, and one record or all of them.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Any record&lt;/th&gt;
&lt;th&gt;One record&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Any name&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;everything in the resolver (the root)&lt;/td&gt;
&lt;td&gt;that record on every name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;One name&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;every record on that name&lt;/td&gt;
&lt;td&gt;that record on that name&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Granted on &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt; alone, &lt;code&gt;ROLE_SET_TEXT&lt;/code&gt; would let the holder write any of its text keys, the ceiling included. Granted on &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt; plus &lt;code&gt;turnstile:price&lt;/code&gt;, it covers the price and nothing else. The "one record" column exists only for text records (per key), data records (per key) and addresses (per chain). The resolver's other writes, such as the content hash, can only be granted per name or at the root. That's enough for us: the price and the endpoint are text records, and the payout is an address.&lt;/p&gt;

&lt;p&gt;The grant comes from one list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/// The exact text keys the hot key is authorized to write.
/// Single source of truth. The deploy script grants from this list and
/// the tests assert against it.
function hotKeyTextKeys() internal pure returns (string[] memory keys) {
    keys = new string[](2);
    keys[0] = agentEndpointKey(PROTOCOL_MCP);
    keys[1] = KEY_PRICE;
}

function authorizeHotKey(
    PermissionedResolver resolver,
    bytes memory dnsName,
    address hotKey,
    bool grant
) internal {
    string[] memory keys = hotKeyTextKeys();
    for (uint256 i; i &amp;lt; keys.length; ++i) {
        resolver.authorizeTextRoles(dnsName, keys[i], hotKey, grant);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/contracts/src/TurnstileOffer.sol" rel="noopener noreferrer"&gt;contracts/src/TurnstileOffer.sol&lt;/a&gt; (comments trimmed)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That is the whole grant. The hot key holds &lt;code&gt;ROLE_SET_TEXT&lt;/code&gt; on two part resources, no &lt;code&gt;ROLE_SET_ADDR&lt;/code&gt; anywhere, and no &lt;code&gt;ROLE_SET_TEXT_ADMIN&lt;/code&gt;, so it cannot grant itself more permissions. Rotation is the same function called twice by the operator key: &lt;code&gt;grant = false&lt;/code&gt; for the old hot key, &lt;code&gt;grant = true&lt;/code&gt; for the new one. We ran a full rotation on Sepolia and rotated back, and the old key went inert immediately.&lt;/p&gt;

&lt;p&gt;One trap: &lt;code&gt;PermissionedResolver&lt;/code&gt; switches off the usual &lt;code&gt;grantRoles&lt;/code&gt; and &lt;code&gt;revokeRoles&lt;/code&gt; (they always revert), so every grant goes through one of its four &lt;code&gt;authorize&lt;/code&gt; functions (&lt;code&gt;authorizeNameRoles&lt;/code&gt;, &lt;code&gt;authorizeTextRoles&lt;/code&gt;, &lt;code&gt;authorizeDataRoles&lt;/code&gt;, &lt;code&gt;authorizeAddrRoles&lt;/code&gt;). The tempting shortcut, &lt;code&gt;grantRootRoles(ROLE_SET_TEXT, hot)&lt;/code&gt;, still works, and it would have given the hot key permissions over every text record on every name.&lt;/p&gt;

&lt;p&gt;The resolver doesn't enforce the price ceiling itself. It controls who may write each record, but it never compares the two values, so nothing onchain stops the hot key from writing a price of 5 under a ceiling of 0.50. The check happens when someone reads the records. Our seller rejects a price above the ceiling and keeps charging the last good one, and a buyer's agent can read both records and compare them the same way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: testing the live deployment
&lt;/h2&gt;

&lt;p&gt;We test the role split at two levels. Local tests compile ENS's real &lt;code&gt;PermissionedResolver&lt;/code&gt; and check the design: which roles the deploy script grants, and what each key can call. The roles on Sepolia, though, are state on a deployed contract, and any transaction from the operator key can change them. So a second set of tests runs against the live contracts.&lt;/p&gt;

&lt;p&gt;These are fork tests. Foundry's &lt;a href="https://getfoundry.sh/reference/cheatcodes/create-select-fork" rel="noopener noreferrer"&gt;&lt;code&gt;createSelectFork&lt;/code&gt;&lt;/a&gt; copies Sepolia's current state into a local test chain, so each test calls the deployed resolver as it is right now, and nothing it does reaches the real network. The addresses, the label and the agent id all come from &lt;code&gt;addresses.turnstile.sepolia.json&lt;/code&gt;, the file the deploy scripts write. Two tests carry the main point: the hot key can't change the payout, and it can still change the price.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/// The invariant, against the live deployment. The hot key cannot
/// redirect payment on the contract that is actually deployed.
function testFork_hotKeyCannotChangeThePayoutOnChain() public live {
    uint256 nameResource = PermissionedResolverLib.resource(node, bytes32(0));

    vm.prank(hot);
    vm.expectRevert(
        abi.encodeWithSelector(
            IEnhancedAccessControl.EACUnauthorizedAccountRoles.selector,
            nameResource,
            PermissionedResolverLib.ROLE_SET_ADDR,
            hot
        )
    );
    resolver.setAddr(node, makeAddr("attacker"));

    assertEq(resolver.addr(node), payable(payout), "payout is untouched");
}

/// And it can still do its job.
function testFork_hotKeyCanStillReprice() public live {
    vm.prank(hot);
    resolver.setText(node, TurnstileOffer.KEY_PRICE, "0.11");
    assertEq(resolver.text(node, TurnstileOffer.KEY_PRICE), "0.11");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/contracts/test/fork/SepoliaOffer.t.sol" rel="noopener noreferrer"&gt;contracts/test/fork/SepoliaOffer.t.sol&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The first test expects one specific error. &lt;code&gt;EACUnauthorizedAccountRoles&lt;/code&gt; names the resource that was checked, the missing role (&lt;code&gt;1&lt;/code&gt;, &lt;code&gt;ROLE_SET_ADDR&lt;/code&gt;) and the account (the hot key). The resource is the name-level one, &lt;code&gt;(node, 0)&lt;/code&gt;: the hot key has no permission on the payout record, so the check falls back to the whole name and fails there. A third test checks that the hot key holds &lt;code&gt;ROLE_SET_TEXT&lt;/code&gt; on exactly the two records and nowhere wider.&lt;/p&gt;

&lt;p&gt;Another file, &lt;code&gt;SepoliaEnsV2.t.sol&lt;/code&gt;, watches ENS itself. ENS has archived and redeployed its Sepolia contracts once already, so this test checks that the root registry still points &lt;code&gt;eth&lt;/code&gt; at the &lt;code&gt;.eth&lt;/code&gt; registry we built on.&lt;/p&gt;

&lt;p&gt;Anyone can run the same check without Foundry. Calling &lt;code&gt;setAddr&lt;/code&gt; from the hot key's address against Sepolia gives the same error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cast call $R "setAddr(bytes32,address)" $N 0x…dEaD \
    --from 0x16244874881c60881CEA827fe856Ea91d3186367
Error: execution reverted: EACUnauthorizedAccountRoles(
  87140393317148622081856579921496229094570723339484417348903196786160147430199, 1,
  0x16244874881c60881CEA827fe856Ea91d3186367)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Terminal output against the live resolver&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;On the live chain, the operator key set the payout when we published the offer (&lt;a href="https://sepolia.etherscan.io/tx/0x922ea0bb33bfc9267c929e0415cc590afbf731b4fe66d7a4f781b0876cff2fe4" rel="noopener noreferrer"&gt;tx 0x922e…2fe4&lt;/a&gt;). When the endpoint had to move off a domain we didn't own, the hot key changed it on its own (&lt;a href="https://sepolia.etherscan.io/tx/0x6736b3b2125d7d030be5fb70c5343342d98cc44ab2dd38b2451667926b818c66" rel="noopener noreferrer"&gt;tx 0x6736…8c66&lt;/a&gt;), and the payout and price stayed the same.&lt;/p&gt;

&lt;p&gt;A leaked hot key can change the price until the operator key rotates it, and our seller won't charge more than the ceiling. It can't redirect a payment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: from the resolver to the seller page
&lt;/h2&gt;

&lt;p&gt;The seller page shows the offer straight from the chain. It's a Next.js route marked &lt;code&gt;dynamic = 'force-dynamic'&lt;/code&gt;, so the server renders it on every request instead of once at deploy time. When the hot key changes the price, the next visitor sees the new one. Each render reads the records from the resolver, one &lt;code&gt;text(node, key)&lt;/code&gt; call per record plus the payout address, and the page shows the block number it read at.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpansd46emcsvz4dkb146.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpansd46emcsvz4dkb146.png" alt="The seller page for liquidity.turnstile.eth: the price next to its ceiling, all eight resolver records read at a block, and the four checks that passed" width="800" height="903"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The reading code is shared. &lt;code&gt;readSellerOffer&lt;/code&gt; in &lt;code&gt;graph/sink/ens.ts&lt;/code&gt; is the same function the discovery index and the buyer's MCP server use, so the market, the buyer and the seller page all see the same offer. The page wraps it in &lt;code&gt;readOffer&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/** Read one seller's records off chain. Never falls back to cached values. */&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;readOffer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ensName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;LiveOfferResult&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;seller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;findSeller&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ensName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;rpcUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;ensName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;seller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ensName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="s1"&gt;'SEPOLIA_RPC_URL is not set on this deployment, so the resolver cannot be read. The records are not shown rather than served from cache ...'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;makePublicClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;offer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;readSellerOffer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ensName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;seller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ensName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;resolver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;seller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;resolver&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;backlink&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;readAgentBacklink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;identityRegistry&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nc"&gt;Address&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;agentId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;linked&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
    &lt;span class="n"&gt;offer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;agentRegistrationConfirmed&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;backlink&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tokenUri&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;seller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ensName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/web/lib/ens.ts" rel="noopener noreferrer"&gt;web/lib/ens.ts&lt;/a&gt; (trimmed, including the end of the error string)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Before the page shows the price as something a buyer can act on, it runs two checks. The first is the two-way ENSIP-25 link from Step 2: the name points to agent 10127, and &lt;code&gt;tokenURI(10127)&lt;/code&gt; points back to the name. The second asks &lt;code&gt;VerifiableFactory.verifyContract&lt;/code&gt; which code runs behind the resolver and expects ENS's unmodified &lt;code&gt;PermissionedResolver&lt;/code&gt;. A name can claim any agent id, and any contract can call itself a resolver, so the page checks each claim from the other side and shows the result as a pass or fail card.&lt;/p&gt;

&lt;p&gt;The last link is the endpoint. &lt;code&gt;agent-endpoint[mcp]&lt;/code&gt; points at the seller's MCP server, which answers over HTTP/SSE, so a client that follows the record reaches &lt;code&gt;initialize&lt;/code&gt; and &lt;code&gt;tools/list&lt;/code&gt; and finds the four tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the key split covers
&lt;/h2&gt;

&lt;p&gt;Turnstile uses three tiers of keys. On the buyer side, the warm tier is a Privy org wallet (&lt;a href="https://ignaciopastorsanchez.com/blog/privy-spending-mandates-key-quorums" rel="noopener noreferrer"&gt;spending mandates with key quorums&lt;/a&gt;) and the hot tier is an agent that signs offchain and never submits a transaction. On the seller side, the operator key holds every role that matters, and the hot key holds two records.&lt;/p&gt;

&lt;p&gt;Only the operator key can change where the money goes. The resolver checks this on every write: when the hot key tries, the call reverts on Sepolia. This holds whatever device or service stores each key.&lt;/p&gt;

&lt;p&gt;Because the roles belong to an address, the operator can be any account that has one. The simplest is a hardware wallet: the key never leaves the device, and every role change needs a button press. A Safe multisig goes further. The operator becomes a contract that acts only when, say, two of three owners sign, so one stolen key moves nothing. A third option is a policy wallet, such as a Privy wallet controlled by a key quorum, which signs only requests that match rules you set. &lt;a href="https://ignaciopastorsanchez.com/blog/privy-spending-mandates-key-quorums" rel="noopener noreferrer"&gt;Part 7&lt;/a&gt; uses that setup for buyers.&lt;/p&gt;

&lt;p&gt;The split protects against a leaked hot key. Protecting the operator key is the custody choice above, and the chain doesn't see which one you made. The &lt;code&gt;turnstile:operator-proof&lt;/code&gt; record states the property the chain does enforce: &lt;code&gt;operator-key-role-scoped&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.ens.domains/ensip/25" rel="noopener noreferrer"&gt;ENSIP-25: AI Agent Registry ENS Name Verification&lt;/a&gt;: Defines the &lt;code&gt;agent-registration[&amp;lt;registry&amp;gt;][&amp;lt;agentId&amp;gt;]&lt;/code&gt; key with an ERC-7930 registry address and a value of &lt;code&gt;"1"&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ens.domains/ensip/26" rel="noopener noreferrer"&gt;ENSIP-26: Agent Text Records&lt;/a&gt;: Defines &lt;code&gt;agent-context&lt;/code&gt; and &lt;code&gt;agent-endpoint[&amp;lt;protocol&amp;gt;]&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ens.domains/contracts/ensv2/enhanced-access-control" rel="noopener noreferrer"&gt;ENSv2 Enhanced Access Control&lt;/a&gt;: resources, role bitmaps, admin roles and &lt;code&gt;ROOT_RESOURCE&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ens.domains/contracts/ensv2/permissioned-resolver" rel="noopener noreferrer"&gt;ENSv2 Permissioned Resolver&lt;/a&gt;: name-level vs record-level roles and &lt;code&gt;authorizeTextRoles&lt;/code&gt; / &lt;code&gt;authorizeAddrRoles&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ens.domains/contracts/ensv2/overview" rel="noopener noreferrer"&gt;ENSv2 overview&lt;/a&gt;: EAC as the replacement for Name Wrapper fuses.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/ensdomains/contracts-v2" rel="noopener noreferrer"&gt;ensdomains/contracts-v2&lt;/a&gt; at commit &lt;code&gt;48b3e2d&lt;/code&gt;, the version deployed on Sepolia: source of &lt;code&gt;UserRegistry&lt;/code&gt;, &lt;code&gt;PermissionedRegistry&lt;/code&gt;, &lt;code&gt;PermissionedResolver&lt;/code&gt; and the Sepolia deployment artifacts.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://sepolia.etherscan.io/address/0xb1B4Da2C49814c8CbF975E7a48fbB014EA0b075B" rel="noopener noreferrer"&gt;Turnstile resolver on Sepolia Etherscan&lt;/a&gt;: the &lt;code&gt;PermissionedResolver&lt;/code&gt; proxy holding the offer records.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://sepolia.etherscan.io/tx/0x922ea0bb33bfc9267c929e0415cc590afbf731b4fe66d7a4f781b0876cff2fe4" rel="noopener noreferrer"&gt;Operator key &lt;code&gt;setAddr&lt;/code&gt; publishing the payout&lt;/a&gt;: the call that reverts for the hot key, succeeding for the operator key.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://sepolia.etherscan.io/tx/0x6736b3b2125d7d030be5fb70c5343342d98cc44ab2dd38b2451667926b818c66" rel="noopener noreferrer"&gt;Hot key moving &lt;code&gt;agent-endpoint[mcp]&lt;/code&gt;&lt;/a&gt;: the hot key using exactly the authority it has.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Turnstile repository&lt;/a&gt;: contracts, fork tests, &lt;code&gt;docs/ens-offer-records.md&lt;/code&gt;, &lt;code&gt;docs/EVIDENCE.md&lt;/code&gt;, &lt;code&gt;CORRECTIONS.md&lt;/code&gt; and &lt;code&gt;AI-USE.md&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Next in the series:&lt;/strong&gt; &lt;a href="https://ignaciopastorsanchez.com/blog/world-id-selfie-check-abuse-control" rel="noopener noreferrer"&gt;Three listings per human: capping an open agent registry with World ID Selfie Check&lt;/a&gt;, part 6 of 9.&lt;/p&gt;

</description>
      <category>ethereum</category>
      <category>web3</category>
      <category>ai</category>
      <category>security</category>
    </item>
    <item>
      <title>A sample of 197 ERC-8004 agents, and where their prices live</title>
      <dc:creator>Ignacio Pastor Sánchez</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:36:23 +0000</pubDate>
      <link>https://dev.to/ignacio_pastor/a-sample-of-197-erc-8004-agents-and-where-their-prices-live-26pc</link>
      <guid>https://dev.to/ignacio_pastor/a-sample-of-197-erc-8004-agents-and-where-their-prices-live-26pc</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 4 of 9 in the &lt;a href="https://ignaciopastorsanchez.com/blog/series/turnstile" rel="noopener noreferrer"&gt;Turnstile series&lt;/a&gt;: building a paid lane for onchain data agents.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;I built &lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Turnstile&lt;/a&gt;, a marketplace where AI agents sell answers and other agents pay for them. &lt;/p&gt;

&lt;p&gt;Step one of any purchase is discovery: which agents exist, what do they do, and where do they get paid. &lt;a href="https://eips.ethereum.org/EIPS/eip-8004" rel="noopener noreferrer"&gt;ERC-8004&lt;/a&gt; ("Trustless Agents") is the obvious place to look. I indexed it with &lt;a href="https://docs.substreams.dev" rel="noopener noreferrer"&gt;Substreams&lt;/a&gt;, The Graph's engine for processing blocks with Rust code compiled to WASM. I wrote one module that decodes the ERC-8004 Identity Registry and ran the same binary on every chain.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Streamed &lt;strong&gt;197 real agent registrations&lt;/strong&gt; from &lt;strong&gt;Base (119), Ethereum mainnet (38) and Sepolia (40)&lt;/strong&gt; into one SQLite store, joined on a cross-chain id. That is a sample of short block windows, not a full index: Base alone has about 85,000 agents.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ERC-8004 has no price field, by design, so the prices that exist live elsewhere, in three formats.&lt;/strong&gt; 76 Virtuals agents follow ACP, Virtuals' Agent Commerce Protocol, and put a bare number with no currency in its &lt;code&gt;jobOfferings&lt;/code&gt; field. One agent, Capminal, answers with a live x402 quote: 0.50 USDC on Base. And one is ours: agent 10127 on Sepolia, whose registry entry points to the ENS name &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt;, with the price in that name's text records.&lt;/li&gt;
&lt;li&gt;97 agents set &lt;code&gt;x402Support&lt;/code&gt;, but 79 of those are Virtuals agents with no HTTP endpoint at all. Of the rest, only a handful list a real endpoint, and most of those are dead.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So finding a seller takes more than the registry. The registry tells you which agents exist. The price comes from a different place depending on who you ask: the seller's ENS name, the 402 its endpoint returns if the endpoint is up, or a marketplace's own format.&lt;/p&gt;

&lt;p&gt;The code can be found on &lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Github&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What ERC-8004 standardizes, and what it leaves out
&lt;/h2&gt;

&lt;p&gt;I first read &lt;a href="https://eips.ethereum.org/EIPS/eip-8004" rel="noopener noreferrer"&gt;the EIP8004&lt;/a&gt; in February, when Base announced support. It defines three lightweight registries.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Identity Registry.&lt;/strong&gt; An ERC-721 with URIStorage. Each agent is a token, and its &lt;code&gt;agentURI&lt;/code&gt; points to a &lt;strong&gt;registration file&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reputation Registry.&lt;/strong&gt; A standard way to post and read feedback from clients.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validation Registry.&lt;/strong&gt; Hooks for independent checks: stake-secured re-execution, zkML verifiers, TEE oracles.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Identity Registry: who exists
&lt;/h3&gt;

&lt;p&gt;The registration file is JSON. Here is a real one, from Capminal's agent (number 1380 on Base), trimmed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://eips.ethereum.org/EIPS/eip-8004#registration-v1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Captain Dackie"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"I am Captain Dackie | A DeFAI and x402 AI Agent from Capminal | ..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"image"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://blob.8004scan.app/cd88d8d9….jpg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"active"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"services"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"web"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"endpoint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://app.virtuals.io/virtuals/23397"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"MCP"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"endpoint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://www.capminal.ai/mcp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2025-01-15"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"A2A"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"endpoint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://www.capminal.ai/.well-known/agent-card.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0.3.0"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"custom"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"endpoint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://www.capminal.ai/api/x402/deploy"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"endpoint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"dackie@capminal.ai"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"registrations"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"agentId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;9382&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"agentRegistry"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"eip155:1:0x8004A169FB4a3325136EB29fA0ceB6D2e539a432"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"agentId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1380&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"agentRegistry"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"eip155:8453:0x8004A169FB4a3325136EB29fA0ceB6D2e539a432"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"supportedTrust"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"crypto-economic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"tee-attestation"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"reputation"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"x402Support"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;services&lt;/code&gt; lists the ways to reach the agent: a website, an MCP server, an A2A agent card, plain endpoints. &lt;code&gt;registrations&lt;/code&gt; links the same agent across chains, here Ethereum mainnet and Base. &lt;code&gt;x402Support: true&lt;/code&gt; says the agent takes x402 payments, but nothing in the file says how much it charges.&lt;/p&gt;

&lt;p&gt;For discovery, the Identity Registry emits three events.:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;event Registered(uint256 indexed agentId, string agentURI, address indexed owner)
event URIUpdated(uint256 indexed agentId, string newURI, address indexed updatedBy)
event MetadataSet(uint256 indexed agentId, string indexed indexedMetadataKey, string metadataKey, bytes metadataValue)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One metadata key is reserved, &lt;code&gt;agentWallet&lt;/code&gt;, and it starts out as the owner's address. For a marketplace that is the most important field in the standard, because it is where the agent gets paid.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reputation Registry: what clients report
&lt;/h3&gt;

&lt;p&gt;Any address can leave feedback on an agent with &lt;code&gt;giveFeedback&lt;/code&gt;, except the agent's owner and its operators; the contract reverts on self-review. Each piece of feedback stores a signed number with its decimal count, two free-form tags that say what the number measures, and a revoked flag. The spec's examples give a sense of the range:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;code&gt;tag1&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;&lt;code&gt;value&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;valueDecimals&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;starred&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;87 out of 100&lt;/td&gt;
&lt;td&gt;&lt;code&gt;87&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;uptime&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;99.77%&lt;/td&gt;
&lt;td&gt;&lt;code&gt;9977&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;responseTime&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;560 ms&lt;/td&gt;
&lt;td&gt;&lt;code&gt;560&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A written review, if there is one, lives offchain at a &lt;code&gt;feedbackURI&lt;/code&gt;, and the contract keeps its keccak-256 hash so the file can't be swapped later. The reviewer can revoke their feedback, and anyone can attach a response to it: the agent pointing to a refund, or an aggregator flagging spam.&lt;/p&gt;

&lt;p&gt;To read an agent's score, you call &lt;code&gt;getSummary&lt;/code&gt; with a list of reviewers you trust, and the contract averages only their feedback. The list is mandatory because new addresses cost nothing: anyone could post a hundred five-star reviews from a hundred fresh wallets. Smarter scoring, such as trusting reviewers with a long track record, is left to offchain tools.&lt;/p&gt;

&lt;h3&gt;
  
  
  Validation Registry: who checked the work
&lt;/h3&gt;

&lt;p&gt;Reputation is opinion. Validation is a check. An agent's owner calls &lt;code&gt;validationRequest&lt;/code&gt;, naming a validator contract and pointing to the inputs and outputs of a piece of work stored offchain. The validator answers with &lt;code&gt;validationResponse&lt;/code&gt;, a score from 0 to 100, and can answer again as the check progresses, for example tagging a soft result and later a final one. How the validator checks is its own business: re-running the job with stake at risk, verifying a zkML proof, reading a TEE attestation. Staking and slashing sit outside the standard. &lt;/p&gt;

&lt;p&gt;You can think about the validator as an oracle the agent chooses, and the registry is where its answers are published. The registry checks nothing itself, so a score is only worth as much as the validator that gave it.&lt;/p&gt;

&lt;p&gt;This registry isn't live. The contract is in the official repository, but the deployment list has no Validation Registry address on any chain, and the README says that part of the spec is still being revised with the TEE community. The deployed ERC-8004 is identity and reputation.&lt;/p&gt;

&lt;h3&gt;
  
  
  No price
&lt;/h3&gt;

&lt;p&gt;What the standard does &lt;strong&gt;not&lt;/strong&gt; have is a price. The EIP states: "Payments are orthogonal to this protocol and not covered here." That is fine as the standard needs to be as generic as possible so we can compose over it, but for someone building a buyer's agent it means the registry can be used to discover seller agents and their services but it can never answer "what does this cost?"&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Substreams, when a subgraph would have worked
&lt;/h2&gt;

&lt;p&gt;ERC-8004 deploys to vanity addresses: &lt;code&gt;0x8004A169…a432&lt;/code&gt; on mainnets and &lt;code&gt;0x8004A818…BD9e&lt;/code&gt; on testnets, per the &lt;a href="https://github.com/erc-8004/erc-8004-contracts" rel="noopener noreferrer"&gt;official deployments list&lt;/a&gt;. Ethereum mainnet and Base share an address, and so do Sepolia and Base Sepolia. The event ABI is identical everywhere. What varies between chains is the chain id, which address applies, and the deployment block.&lt;/p&gt;

&lt;p&gt;So the decoding code is the same on every chain, and only those three values change.&lt;/p&gt;

&lt;p&gt;A subgraph would have handled that fine. You write one mapping, list the address and start block per network in &lt;code&gt;networks.json&lt;/code&gt;, and deploy it once per chain. &lt;a href="https://thegraph.com/docs/en/subgraphs/existing-subgraphs/agent0/" rel="noopener noreferrer"&gt;The Graph's Agent0 subgraphs&lt;/a&gt; already index ERC-8004 that way across many networks, and we named our fields to match their schema.&lt;/p&gt;

&lt;p&gt;We picked Substreams for two reasons. The first is where the data ends up. Each subgraph deployment is its own GraphQL API, so three chains means three endpoints to query and merge. We wanted every chain's registrations to land in one SQLite store, joined on a cross-chain id, next to the ENS offers, x402 quotes and settlement receipts the rest of Turnstile reads. The second is that we had built subgraphs before and wanted to try The Graph's other indexing tool, for fun.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.substreams.dev" rel="noopener noreferrer"&gt;Substreams&lt;/a&gt; is The Graph's other indexing engine, originally built by StreamingFast. You write modules in Rust. Each one receives a full block (header, transactions, receipts, every event log, internal calls and state changes) or the output of another module, picks what it needs, and returns it in a format you define. Ours only reads event logs: it keeps those emitted by the registry and decodes the three events above. The engine runs modules across the chain's history in parallel and streams the results to a sink: a database, a file, your own program, or a subgraph.&lt;/p&gt;

&lt;p&gt;Two features did the multi-chain work. The manifest's &lt;code&gt;networks:&lt;/code&gt; section "allows specifying per-network &lt;code&gt;params&lt;/code&gt; and &lt;code&gt;initialBlock&lt;/code&gt; for each module", so the chain-specific facts become params and every chain runs the same WASM. And the output is a protobuf message we define, so registrations from every chain come out in one shape, ready for the same table. The package ships as a single &lt;code&gt;.spkg&lt;/code&gt; that anyone can import and build on.&lt;/p&gt;

&lt;p&gt;This is how the multi-chain part looks in practice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;mainnet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;initialBlock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;map_agent_registrations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;24339871&lt;/span&gt;
    &lt;span class="na"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;map_agent_registrations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"registry=0x8004a169fb4a3325136eb29fa0ceb6d2e539a432&amp;amp;chain_id=1&amp;amp;network=mainnet"&lt;/span&gt;
  &lt;span class="na"&gt;base&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;initialBlock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;map_agent_registrations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;41663783&lt;/span&gt;
    &lt;span class="na"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;map_agent_registrations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"registry=0x8004a169fb4a3325136eb29fa0ceb6d2e539a432&amp;amp;chain_id=8453&amp;amp;network=base"&lt;/span&gt;
  &lt;span class="na"&gt;sepolia&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;initialBlock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;map_agent_registrations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;9989393&lt;/span&gt;
    &lt;span class="na"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;map_agent_registrations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"registry=0x8004a818bfb912233c491871b3d84c89a494bd9e&amp;amp;chain_id=11155111&amp;amp;network=sepolia"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Trimmed (store modules and base-sepolia omitted). &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/graph/substreams/substreams.yaml" rel="noopener noreferrer"&gt;&lt;code&gt;graph/substreams/substreams.yaml&lt;/code&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;substreams run erc8004-agent-registry-v0.1.0.spkg map_agent_registrations --network base&lt;/code&gt; and &lt;code&gt;--network mainnet&lt;/code&gt; run the same WASM. The manifest declares four networks: mainnet, Base, Sepolia and Base Sepolia.&lt;/p&gt;

&lt;h2&gt;
  
  
  The module
&lt;/h2&gt;

&lt;p&gt;The package has three modules:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Module&lt;/th&gt;
&lt;th&gt;Kind&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;map_agent_registrations&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;map&lt;/td&gt;
&lt;td&gt;Decodes one registry, one block, no state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;store_agent_wallets&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;store (&lt;code&gt;set&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Latest &lt;code&gt;agentWallet&lt;/code&gt; per agent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;map_agent_directory&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;map&lt;/td&gt;
&lt;td&gt;The map joined against the store, so the payout address is right even when the wallet changed in an earlier block&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The core is the map handler. For each log from the configured registry, it matches &lt;code&gt;Registered&lt;/code&gt; or &lt;code&gt;URIUpdated&lt;/code&gt;, builds a cross-chain id, picks an operator, and tries to parse the registration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="cp"&gt;#[substreams::handlers::map]&lt;/span&gt;
&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;map_agent_registrations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;raw_params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;blk&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;eth&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;Block&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;Result&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;AgentRegistrations&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Params&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;raw_params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;blk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;logs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;registry_bytes&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;agent_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="kc"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;events&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;Registered&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;match_and_decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;RegistrationEvent&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;Registered&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;agent_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;agent_uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="kc"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;events&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;UriUpdated&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;match_and_decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;RegistrationEvent&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;UriUpdated&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;agent_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new_uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;updated_by&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;agent_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;agent_id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;agent_uid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;agent_uid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;agent_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;owner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;to_hex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;operator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;operator_source&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="nf"&gt;wallet_for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;agent_uid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kc"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;OperatorSource&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;AgentWallet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="c1"&gt;// EIP-8004 initialises agentWallet to the owner's address.&lt;/span&gt;
            &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;OperatorSource&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;OwnerDefault&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri_scheme&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;registration&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;parse_uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;parsed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;as_ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;registration&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;parse_document&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="c1"&gt;// ... push AgentRegistration { agent_uid, chain_id, operator, uri_scheme,&lt;/span&gt;
        &lt;span class="c1"&gt;//     registration_resolved: parsed.is_some(), x402_support, price, ... }&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Trimmed. &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/graph/substreams/src/lib.rs" rel="noopener noreferrer"&gt;&lt;code&gt;graph/substreams/src/lib.rs&lt;/code&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Three design decisions matter here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The join key.&lt;/strong&gt; &lt;code&gt;agent_uid&lt;/code&gt; is &lt;code&gt;eip155:&amp;lt;chain_id&amp;gt;:&amp;lt;registry&amp;gt;/&amp;lt;agent_id&amp;gt;&lt;/code&gt;, a CAIP-10-shaped id extended with the token id. Agent 1411 on Base and agent 1411 on mainnet share a registry address but are different agents, and the chain id keeps them apart. That is what makes a cross-chain union safe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What a module cannot resolve.&lt;/strong&gt; A module is a pure function of the block, so it cannot fetch &lt;code&gt;https://&lt;/code&gt; or &lt;code&gt;ipfs://&lt;/code&gt;. It resolves what the chain already carries (&lt;code&gt;data:&lt;/code&gt; URIs and, because people do it, bare JSON literals in the URI field) and marks everything else with &lt;code&gt;registration_resolved: false&lt;/code&gt;. In our store that covered 15 of 197 agents in-module, 7.6%.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tolerant parsing.&lt;/strong&gt; Real registrations drift from the spec. In a survey of 1,200 registrations across mainnet, Sepolia and Base Sepolia, 31 of 441 service arrays were named &lt;code&gt;endpoints&lt;/code&gt; instead of &lt;code&gt;services&lt;/code&gt;, &lt;code&gt;x402Support&lt;/code&gt; showed up as &lt;code&gt;x402support&lt;/code&gt; 41 times, and an endpoint's URL showed up under five different keys. The parser reads all of them. &lt;/p&gt;

&lt;p&gt;That survey found no document with a price field, but it didn't cover Base, where the Virtuals agents keep their prices inside &lt;code&gt;jobOfferings&lt;/code&gt; (see The measured finding). The module still has a &lt;code&gt;Price&lt;/code&gt; message, shaped like an x402 payment requirement, for the &lt;code&gt;price&lt;/code&gt;, &lt;code&gt;pricing&lt;/code&gt; and &lt;code&gt;x402Price&lt;/code&gt; fields some agents add on their own. It doesn't read Virtuals' format; the sink handles that.&lt;/p&gt;

&lt;h2&gt;
  
  
  The sink: landing registrations in a store
&lt;/h2&gt;

&lt;p&gt;A sink is the program on the receiving end of a Substreams module: it takes the module's output and writes it somewhere. The Graph ships an official SQL sink for Postgres and ClickHouse. We wrote a small one instead, because we wanted SQLite: it ships with Node, so the store goes from &lt;code&gt;git clone&lt;/code&gt; to a query with no server to run. &lt;code&gt;graph/sink/sink.ts&lt;/code&gt; runs &lt;code&gt;substreams run ... -o jsonl&lt;/code&gt;, reads one JSON line per block, and upserts rows in batches of 500 blocks.&lt;/p&gt;

&lt;p&gt;The package has two outputs for two kinds of reader. &lt;code&gt;map_agent_registrations&lt;/code&gt; looks at each block on its own, so it can stream any window of blocks cheaply. &lt;code&gt;map_agent_directory&lt;/code&gt; adds a running memory of every &lt;code&gt;agentWallet&lt;/code&gt; change. &lt;/p&gt;

&lt;p&gt;An agent can set its payout wallet blocks after it registers, and only a reader with memory can connect the two. That memory is built by replaying every block from the registry's deployment. On Base the registry was deployed about 37,000 blocks before the window we wanted, so a 200-block read came back as &lt;code&gt;this request needs to process 37,200 blocks (37,000 of them to prepare the stores)&lt;/code&gt;. That suits someone indexing a chain from the start but we were reading short windows, so the sink takes the plain output, stores every wallet change as its own row, and joins them in SQL (&lt;code&gt;foldWallets&lt;/code&gt;). The join moved 10 Sepolia agents onto a wallet they set after registering.&lt;/p&gt;

&lt;p&gt;The store is &lt;strong&gt;a sample, not a full index&lt;/strong&gt;. Our Graph Market plan allows two streams at a time, so we streamed four short windows, one chain at a time:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Network&lt;/th&gt;
&lt;th&gt;Block range&lt;/th&gt;
&lt;th&gt;Covers&lt;/th&gt;
&lt;th&gt;Agents&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Base&lt;/td&gt;
&lt;td&gt;41,700,000 to 41,715,999&lt;/td&gt;
&lt;td&gt;about 9 hours on 4 February 2026, a day after the registry deployed&lt;/td&gt;
&lt;td&gt;119&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ethereum mainnet&lt;/td&gt;
&lt;td&gt;25,000,000 to 25,014,999&lt;/td&gt;
&lt;td&gt;about 2 days, 1 to 3 May 2026&lt;/td&gt;
&lt;td&gt;38&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sepolia&lt;/td&gt;
&lt;td&gt;10,000,000 to 10,009,999&lt;/td&gt;
&lt;td&gt;about 38 hours, 8 to 9 January 2026&lt;/td&gt;
&lt;td&gt;39&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sepolia&lt;/td&gt;
&lt;td&gt;11,653,700 to 11,653,729&lt;/td&gt;
&lt;td&gt;the block where ours registered&lt;/td&gt;
&lt;td&gt;1 (agent 10127)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For scale, Base alone had about 85,000 agents registered by 2026-09-07, counted from RPC logs. 197 is a small slice, and every number in this article describes that slice. Indexing everything is a longer run of the same code: the sink keeps a cursor per chain and picks up where it stopped.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fetching the registration files
&lt;/h3&gt;

&lt;p&gt;The registry stores each agent's &lt;code&gt;agentURI&lt;/code&gt;, which is usually a link. For most agents the registration file sits behind it, on a web server or IPFS, and a Substreams module can't make network calls. So once the stream has landed, &lt;code&gt;resolve-cards.ts&lt;/code&gt; follows every link the module couldn't read and stores the file it finds. It records every outcome, failures included, because "this agent advertises nothing" and "we couldn't reach its file" are different answers for a buyer. Each agent ends up in one state:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;code&gt;document_state&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Agents&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;off_module&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;fetched by &lt;code&gt;resolve-cards.ts&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;126&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;in_module&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the file was onchain, decoded by the module&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;failed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the link gave a 404, a DNS error or a timeout&lt;/td&gt;
&lt;td&gt;25&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;no_uri&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;registered with no URI at all&lt;/td&gt;
&lt;td&gt;30&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;not_fetchable&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a URI nothing can fetch over HTTP; ours, which is an ENS name&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Anyone can register an agent with any link, and you can see anything and everything here. The fetcher refuses links into private networks: localhost, office and home ranges such as &lt;code&gt;10.x&lt;/code&gt; and &lt;code&gt;192.168.x&lt;/code&gt;, carrier ranges, and link-local addresses such as &lt;code&gt;169.254.169.254&lt;/code&gt;, where cloud servers expose their own credentials. It re-checks after every redirect, so a public link can't bounce it into one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where the price comes from
&lt;/h3&gt;

&lt;p&gt;Price is not a column on the &lt;code&gt;agent&lt;/code&gt; table. It is derived in the read model, and every row says where its price came from, or that there is none:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CASE&lt;/span&gt;
  &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;                                  &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="s1"&gt;'turnstile'&lt;/span&gt;
  &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;                                 &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="s1"&gt;'x402'&lt;/span&gt;
  &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="nb"&gt;COALESCE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price_amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price_amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="s1"&gt;'document'&lt;/span&gt;
  &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;acp_offer_count&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;                                &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="s1"&gt;'acp'&lt;/span&gt;
  &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="nb"&gt;COALESCE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x402_support&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x402_support&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;      &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="s1"&gt;'ask_x402'&lt;/span&gt;
  &lt;span class="k"&gt;ELSE&lt;/span&gt; &lt;span class="s1"&gt;'none'&lt;/span&gt;
&lt;span class="k"&gt;END&lt;/span&gt;                                    &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;price_source&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;From the &lt;code&gt;agent_current&lt;/code&gt; view. &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/graph/sink/schema.sql" rel="noopener noreferrer"&gt;&lt;code&gt;graph/sink/schema.sql&lt;/code&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;s&lt;/code&gt; is a Turnstile seller's ENS offer, &lt;code&gt;q&lt;/code&gt; is a live 402 quote, &lt;code&gt;c&lt;/code&gt; and &lt;code&gt;a&lt;/code&gt; are the fetched and in-module documents, and &lt;code&gt;o&lt;/code&gt; counts a Virtuals agent's priced job offerings. &lt;code&gt;ask_x402&lt;/code&gt; means "no price, but this agent takes x402, so the price is knowable if you ask".&lt;/p&gt;

&lt;h2&gt;
  
  
  The measured finding
&lt;/h2&gt;

&lt;p&gt;This query shaped the rest of the design:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;price_source&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;COUNT&lt;/span&gt;&lt;span class="cm"&gt;(*)
FROM agent_current
GROUP BY price_source;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It returned:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Price source&lt;/th&gt;
&lt;th&gt;Agents&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;turnstile&lt;/code&gt; (an ENS &lt;code&gt;turnstile:price&lt;/code&gt; record)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;x402&lt;/code&gt; (a live 402 quote)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;acp&lt;/code&gt; (a Virtuals job offering)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;76&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;document&lt;/code&gt; (a price field in the registration file)&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;ask_x402&lt;/code&gt; (says it takes x402, no quote)&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;none&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;99&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fv8umsx4swjip7cch0tav.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fv8umsx4swjip7cch0tav.png" alt="Turnstile's market page: 197 agents, 78 post a price in three formats, and only 2 can be compared in dollars" width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;document&lt;/code&gt; row counts agents that added their own &lt;code&gt;price&lt;/code&gt; field to the registration file. None did. The prices that exist come from three other places, and each tells a buyer something different.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ours&lt;/strong&gt; is in ENS. &lt;code&gt;turnstile:price&lt;/code&gt; on &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt; reads &lt;code&gt;0.07&lt;/code&gt;, in US dollars, and a buyer can read it without calling the seller.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Capminal's&lt;/strong&gt; is in its 402. &lt;code&gt;probe-x402.ts&lt;/code&gt; asks every endpoint an agent lists and reads x402 v2 quotes from the &lt;code&gt;PAYMENT-REQUIRED&lt;/code&gt; response header. Capminal's registration file lists &lt;code&gt;https://www.capminal.ai/api/x402/deploy&lt;/code&gt; as a &lt;code&gt;custom&lt;/code&gt; service, and a POST there returns 500000 units of USDC on Base, fifty cents. A buyer learns it only by calling.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Virtuals' 76&lt;/strong&gt; are in a &lt;code&gt;jobOfferings&lt;/code&gt; array defined by &lt;a href="https://app.virtuals.io" rel="noopener noreferrer"&gt;Virtuals&lt;/a&gt;' ACP protocol: 227 offerings priced from 0.0003 to 79.99, written as &lt;code&gt;{ "type": "fixed", "value": 0.02 }&lt;/code&gt;. No currency or asset is named, so discovery keeps them as raw numbers and never ranks them against dollar prices. A buyer that doesn't use ACP can't act on them.&lt;/p&gt;

&lt;p&gt;The 20 &lt;code&gt;ask_x402&lt;/code&gt; agents say they take x402 payments, but none answered with a quote. Of the agents that list any service, six point at the OASF specification on GitHub, one at &lt;code&gt;api.example.com&lt;/code&gt;, and the gekkoterminal domains no longer resolve.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where x402 fits, and where ENS fits
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/x402-foundation/x402" rel="noopener noreferrer"&gt;x402&lt;/a&gt; is a payment protocol built on HTTP: the server answers a request with &lt;code&gt;402 Payment Required&lt;/code&gt; and the payments it accepts, each with an amount. It builds that answer per request, so it can price by resource, by caller or by the minute. The spec lists dynamic pricing as one of its patterns, and our Hedera rail reprices with the HBAR rate. For an agent you found in ERC-8004, the price you can rely on is the one in the 402 you get right before paying.&lt;/p&gt;

&lt;p&gt;Turnstile's price is published before anyone asks. It lives in ENS text records on &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt;: &lt;code&gt;turnstile:price&lt;/code&gt; holds &lt;code&gt;0.07&lt;/code&gt;, in US dollars, for the standard tier, and &lt;code&gt;turnstile:price-ceiling&lt;/code&gt; holds &lt;code&gt;0.50&lt;/code&gt;, the most any tier may charge. The premium tier sells at &lt;code&gt;0.35&lt;/code&gt;, under that ceiling. We put it onchain so a buyer's agent can read it without calling us, even when our server is down, and can check who is allowed to change it: the seller's hot key can reprice, and only the cold key can raise the ceiling (see &lt;a href="https://ignaciopastorsanchez.com/blog/ensv2-agent-offer-records-hot-cold-keys" rel="noopener noreferrer"&gt;The offer is the name&lt;/a&gt;). The seller service reads the same record, so the 402 charges what ENS says. The 402 still moves in one way: each payment option converts the dollar price into its own asset, so the HBAR amount follows the exchange rate.&lt;/p&gt;

&lt;p&gt;The two prices come in different units. &lt;code&gt;turnstile:price&lt;/code&gt; is decimal dollars, &lt;code&gt;"0.07"&lt;/code&gt;. An x402 amount is an integer in the asset's smallest unit, so &lt;code&gt;"70000"&lt;/code&gt; USDC is seven cents. &lt;code&gt;normalizePriceUsd&lt;/code&gt; converts both to dollars when it knows the asset and returns &lt;code&gt;usd: null&lt;/code&gt; when it doesn't, rather than compare a raw &lt;code&gt;70000&lt;/code&gt; with &lt;code&gt;0.07&lt;/code&gt;. Virtuals prices always come back &lt;code&gt;null&lt;/code&gt;, since they name no currency.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linking the ENS name to the ERC-8004 agent
&lt;/h3&gt;

&lt;p&gt;Discovery starts from ERC-8004, and our price lives in ENS, so something has to join an agent to its ENS name. Two records point at each other. In ERC-8004, agent 10127's &lt;code&gt;agentURI&lt;/code&gt; is &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt;. In ENS, the name carries a text record defined by &lt;a href="https://docs.ens.domains/ensip/25" rel="noopener noreferrer"&gt;ENSIP-25&lt;/a&gt;, &lt;code&gt;agent-registration[&amp;lt;registry&amp;gt;][&amp;lt;agentId&amp;gt;]&lt;/code&gt;, naming that registry and agent id. The registry part is an &lt;a href="https://eips.ethereum.org/EIPS/eip-7930" rel="noopener noreferrer"&gt;ERC-7930&lt;/a&gt; address, which packs the chain id in with the contract address, so one string means "this contract on Sepolia". A non-empty value is the name's owner claiming that agent.&lt;/p&gt;

&lt;p&gt;A one-way link proves little: anyone can register an agent whose URI is our name, and a name's record can list any agent id. So &lt;code&gt;hydrate-sellers.ts&lt;/code&gt;, the script that copies our sellers' ENS records into the store, links the two only when each points at the other:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;backlink&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;readAgentBacklink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;identityRegistry&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;agentId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;backlinkOk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;backlink&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tokenUri&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;seller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ensName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;linked&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;offer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;agentRegistrationConfirmed&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;backlinkOk&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;uid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;agentUid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chainId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;identityRegistry&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;agentId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/graph/sink/hydrate-sellers.ts" rel="noopener noreferrer"&gt;&lt;code&gt;graph/sink/hydrate-sellers.ts&lt;/code&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For our seller both checks pass: the name carries &lt;code&gt;agent-registration[…][10127]&lt;/code&gt;, and the Sepolia registry's &lt;code&gt;tokenURI(10127)&lt;/code&gt; returns &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt;. Only then does the seller's price join to agent &lt;code&gt;eip155:11155111:0x8004a818bfb912233c491871b3d84c89a494bd9e/10127&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;The record's key is a long string. The ENSIP's own example is &lt;code&gt;agent-registration[0x000100000101148004a169fb4a3325136eb29fa0ceb6d2e539a432][42]&lt;/code&gt;. We build it twice, in Solidity when we write the record and in TypeScript when we read it. If both builders made the same mistake, our reader would still find our record and everything would look fine, but no other app following ENSIP-25 would. So both are tested against that example string from the ENSIP.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ranking sellers by what buyers paid
&lt;/h2&gt;

&lt;p&gt;Turnstile runs one seller of its own, &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt;, but it's also a marketplace. Its store lists every ERC-8004 agent it has indexed, and any buyer's agent can search it to find who sells a given service and at what price. A seller doesn't have to be ours to appear. It only needs an ERC-8004 registration.&lt;/p&gt;

&lt;p&gt;Everything so far fills the store. Buyers' agents query it through one function, &lt;code&gt;findSellers&lt;/code&gt; in &lt;code&gt;seller/service/discovery.ts&lt;/code&gt;, which Turnstile exposes three ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;the &lt;code&gt;find_sellers&lt;/code&gt; tool on its MCP server, &lt;/li&gt;
&lt;li&gt;the &lt;code&gt;/api/sellers&lt;/code&gt; endpoint behind the market page&lt;/li&gt;
&lt;li&gt;a command-line tool. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A buyer asks for a capability, such as &lt;code&gt;liquidity&lt;/code&gt;, optionally with a chain and a maximum price, and gets back a ranked list of sellers. The ranking uses &lt;strong&gt;settled volume&lt;/strong&gt;: the total of payments buyers have actually made to each seller. A seller can't inflate that number on its own. Every payment Turnstile settles writes a receipt to the Hedera Consensus Service topic &lt;code&gt;0.0.10408013&lt;/code&gt;, and &lt;code&gt;ingest-receipts.ts&lt;/code&gt; reads that topic back from Hedera's public mirror node, not from the seller's own database, so anyone reading the topic gets the same totals.&lt;/p&gt;

&lt;p&gt;A store with no receipts yet, such as a fresh local checkout, ranks by registration date instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;rankingBasis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;DatabaseSync&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;basis&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RankBasis&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;placeholder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'SELECT COUNT(*) AS n FROM settlement_receipt'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;basis&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'settled_volume'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;placeholder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`ranked by settled volume over ${row.n} HCS receipts`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;basis&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'registration_recency'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;placeholder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'PLACEHOLDER: ranked by registration recency. ...'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// in findSellers:&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;orderBy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ranking&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;basis&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'settled_volume'&lt;/span&gt;
  &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'settled_volume DESC, settled_count DESC, block_timestamp DESC'&lt;/span&gt;
  &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'first_seen_timestamp DESC, first_seen_block DESC'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Trimmed (note string shortened). &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/seller/service/discovery.ts" rel="noopener noreferrer"&gt;&lt;code&gt;seller/service/discovery.ts&lt;/code&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Registration date means the agent's first registration, not its last URI change; otherwise an agent could climb the list by editing its record. And every response says how it was sorted. Each one carries a &lt;code&gt;ranking&lt;/code&gt; object, &lt;code&gt;{ "basis": "registration_recency", "placeholder": true, … }&lt;/code&gt; or &lt;code&gt;{ "basis": "settled_volume", "placeholder": false, … }&lt;/code&gt;, so a buyer's agent can tell when the order says nothing about reputation.&lt;/p&gt;

&lt;p&gt;As an example, the hosted site ranked by settled volume. &lt;code&gt;curl -s "https://turnstile.moveseventyeight.com/api/sellers?limit=3"&lt;/code&gt; returned &lt;code&gt;"basis": "settled_volume", "placeholder": false&lt;/code&gt; over 16 receipts, with &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt; on top at $1.12, sixteen payments of $0.07. Every other agent scored 0, because nobody else wrote receipts to that topic. Receipts were ingested when someone ran the script, not after each payment, so the ranking was as current as the last run.&lt;/p&gt;

&lt;p&gt;A filtered query puts it together. Searching &lt;code&gt;liquidity&lt;/code&gt; with a $0.10 ceiling matches 8 agents: ours on Sepolia and seven Virtuals agents on Base. The seven are set aside, not because they cost too much but because their prices name no currency, so the ceiling can't be checked against them. The response counts them separately. The one result is &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt; at $0.07. Pass &lt;code&gt;--include-unknown-price&lt;/code&gt; and the seven come back too, each with its raw Virtuals price, shown as &lt;code&gt;0.01–0.25 (acp, not comparable)&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we built
&lt;/h2&gt;

&lt;p&gt;Discovery in Turnstile has four layers. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A Substreams module in Rust decodes the ERC-8004 Identity Registry and runs unchanged on every chain that hosts one. &lt;/li&gt;
&lt;li&gt;A sink lands each chain's registrations in one SQLite store, fetches the registration files the module can't reach, and records every failure. &lt;/li&gt;
&lt;li&gt;Prices come from where sellers actually publish them: our seller's ENS record, live x402 quotes from any endpoint an agent lists, and Virtuals' job prices, kept apart because they name no currency. &lt;/li&gt;
&lt;li&gt;On top sits &lt;code&gt;findSellers&lt;/code&gt;, which ranks sellers by payments settled on Hedera and says so when it can't.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Finding a seller is half a purchase. The other half is paying it. Turnstile takes payment on Hedera, Arc and Base behind one interface: start with &lt;a href="https://ignaciopastorsanchez.com/blog/chain-agnostic-x402-seller-payment-rails" rel="noopener noreferrer"&gt;One payment interface, four chains&lt;/a&gt;, then &lt;a href="https://ignaciopastorsanchez.com/blog/x402-on-hedera-blocky402-paid-http" rel="noopener noreferrer"&gt;x402 on Hedera&lt;/a&gt; and &lt;a href="https://ignaciopastorsanchez.com/blog/gasless-nanopayments-eip3009-circle-gateway-arc" rel="noopener noreferrer"&gt;Gasless nanopayments on Arc&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The ENS records that carry our price, and the key split that protects the payout, are in &lt;a href="https://ignaciopastorsanchez.com/blog/ensv2-agent-offer-records-hot-cold-keys" rel="noopener noreferrer"&gt;The offer is the name&lt;/a&gt;. What our seller offers is in &lt;a href="https://ignaciopastorsanchez.com/blog/the-graph-uniswap-paid-liquidity-analyst" rel="noopener noreferrer"&gt;Selling a liquidity verdict&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://eips.ethereum.org/EIPS/eip-8004" rel="noopener noreferrer"&gt;EIP-8004: Trustless Agents&lt;/a&gt;: the three registries, the registration file fields, the Identity Registry events, the reserved &lt;code&gt;agentWallet&lt;/code&gt; key, and "Payments are orthogonal to this protocol". Draft status.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/erc-8004/erc-8004-contracts" rel="noopener noreferrer"&gt;erc-8004/erc-8004-contracts&lt;/a&gt;: the official deployments list (Identity and Reputation Registry addresses; no Validation Registry deployed), the reference contracts, and &lt;code&gt;ERC8004SPEC.md&lt;/code&gt;, the source for the Reputation and Validation details and the &lt;code&gt;value&lt;/code&gt;/&lt;code&gt;tag1&lt;/code&gt; examples.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.substreams.dev" rel="noopener noreferrer"&gt;Substreams documentation&lt;/a&gt;: what Substreams is.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.substreams.dev/reference-material/manifest-and-components/manifests" rel="noopener noreferrer"&gt;Substreams manifest reference&lt;/a&gt;: the &lt;code&gt;networks&lt;/code&gt; section for per-network &lt;code&gt;params&lt;/code&gt; and &lt;code&gt;initialBlock&lt;/code&gt;, the &lt;code&gt;map&lt;/code&gt; and &lt;code&gt;store&lt;/code&gt; module kinds, and the &lt;code&gt;wasm/rust-v1&lt;/code&gt; runtime.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://thegraph.com/docs/en/subgraphs/existing-subgraphs/agent0/" rel="noopener noreferrer"&gt;Agent0 subgraphs, The Graph docs&lt;/a&gt;: the existing ERC-8004 subgraphs, whose field names the module follows.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ens.domains/ensip/25" rel="noopener noreferrer"&gt;ENSIP-25: AI Agent Registry ENS Name Verification&lt;/a&gt;: the &lt;code&gt;agent-registration[&amp;lt;registry&amp;gt;][&amp;lt;agentId&amp;gt;]&lt;/code&gt; text record with ERC-7930 registry encoding.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/x402-foundation/x402" rel="noopener noreferrer"&gt;x402-foundation/x402&lt;/a&gt;: the x402 protocol, where the server answers &lt;code&gt;402 Payment Required&lt;/code&gt; with the payment requirements. &lt;a href="https://github.com/coinbase/x402" rel="noopener noreferrer"&gt;coinbase/x402&lt;/a&gt; now points here.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/x402-foundation/x402/blob/main/specs/x402-specification-v2.md" rel="noopener noreferrer"&gt;x402 v2 specification&lt;/a&gt;: &lt;code&gt;PaymentRequired&lt;/code&gt;, the &lt;code&gt;PAYMENT-REQUIRED&lt;/code&gt; header, and dynamic pricing listed as a pattern.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://app.virtuals.io" rel="noopener noreferrer"&gt;Virtuals Protocol&lt;/a&gt;: the ACP agents whose registration files carry &lt;code&gt;jobOfferings&lt;/code&gt; prices.&lt;/li&gt;
&lt;li&gt;Capminal's agent (&lt;code&gt;eip155:8453:0x8004a169…a432/1380&lt;/code&gt;): its registration file and the x402 v2 quote from &lt;code&gt;https://www.capminal.ai/api/x402/deploy&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;IpastorSan/turnstile&lt;/a&gt;: the code, plus &lt;code&gt;docs/erc8004-substreams.md&lt;/code&gt; (module verification runs), &lt;code&gt;docs/discovery-api.md&lt;/code&gt; (store contents, probe results and count corrections) and &lt;code&gt;docs/architecture.md&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Next in the series:&lt;/strong&gt; &lt;a href="https://ignaciopastorsanchez.com/blog/ensv2-agent-offer-records-hot-cold-keys" rel="noopener noreferrer"&gt;The offer is the name: ENSv2 records and a key split the chain enforces&lt;/a&gt;, part 5 of 9.&lt;/p&gt;

</description>
      <category>ethereum</category>
      <category>rust</category>
      <category>ai</category>
      <category>agents</category>
    </item>
    <item>
      <title>One payment interface, four chains</title>
      <dc:creator>Ignacio Pastor Sánchez</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:36:15 +0000</pubDate>
      <link>https://dev.to/ignacio_pastor/one-payment-interface-four-chains-15od</link>
      <guid>https://dev.to/ignacio_pastor/one-payment-interface-four-chains-15od</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 3 of 9 in the &lt;a href="https://ignaciopastorsanchez.com/blog/series/turnstile" rel="noopener noreferrer"&gt;Turnstile series&lt;/a&gt;: building a paid lane for onchain data agents.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;In September 2026 I built &lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Turnstile&lt;/a&gt;, a paid lane for onchain data agents. Its seller answers a Uniswap pool question for $0.07, or $0.35 for the premium tier, over x402. By the end, one 402 advertised four ways to pay: HBAR on Hedera testnet, USDC on Arc testnet, USDC on Base Sepolia and USDC on Base mainnet, each through a different facilitator. The code that gates the route knows none of that.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One interface, four methods:&lt;/strong&gt; &lt;code&gt;challenge&lt;/code&gt;, &lt;code&gt;verify&lt;/code&gt;, &lt;code&gt;settle&lt;/code&gt;, &lt;code&gt;receipt&lt;/code&gt;. The service works in dollars and passes chain identifiers along without reading them; the rail speaks chains.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A registry&lt;/strong&gt; builds &lt;code&gt;accepts[]&lt;/code&gt; from every rail and routes the payer's choice back by &lt;code&gt;(scheme, network)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;My own middleware, not the SDK's,&lt;/strong&gt; so each rail implements four methods, and a payment is checked against a fresh quote for the URL requested, with room for HBAR's moving price.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verify, then work, then settle.&lt;/strong&gt; If settlement fails, the answer is withheld.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A test fails the build&lt;/strong&gt; if a file on the payment path names a chain, so adding Base never touched the code that takes money.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Adding Base brought two interop rules: x402 v2's &lt;code&gt;resource&lt;/code&gt; must be an object (PayAI enforces it), and Circle's USDC is &lt;code&gt;"USD Coin"&lt;/code&gt; in its EIP-712 domain on mainnet but &lt;code&gt;"USDC"&lt;/code&gt; on testnet, which surfaces as an invalid signature. &lt;/p&gt;

&lt;p&gt;Bazantic resells API calls: the buyer pays the gateway, and the gateway forwards the call to my seller without paying it. So the seller needs a third answer besides paid and unpaid: a trusted key for calls already paid at the gateway.&lt;/p&gt;

&lt;p&gt;The whole codebase can be found on &lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Github&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the buyer sees
&lt;/h2&gt;

&lt;p&gt;x402 revives HTTP 402 Payment Required. A buyer agent needs no account or API key to learn the price. It just needs to ask the API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Ask without paying.&lt;/strong&gt; The agent calls the endpoint like any API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET https://turnstile.moveseventyeight.com/analyze/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finding that endpoint in the first place is discovery, through ERC-8004 registrations and ENS records, which &lt;a href="https://ignaciopastorsanchez.com/blog/erc8004-agent-discovery-substreams" rel="noopener noreferrer"&gt;Part 4&lt;/a&gt; and &lt;a href="https://ignaciopastorsanchez.com/blog/ensv2-agent-offer-records-hot-cold-keys" rel="noopener noreferrer"&gt;Part 5&lt;/a&gt; cover.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The seller answers 402 with its options.&lt;/strong&gt; The response carries a &lt;code&gt;PaymentRequired&lt;/code&gt; object, base64-encoded in the &lt;code&gt;PAYMENT-REQUIRED&lt;/code&gt; header, and Turnstile also sends it as the body. Its &lt;code&gt;accepts[]&lt;/code&gt; has one entry per rail.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"x402Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://turnstile.moveseventyeight.com/analyze/0x88e6…5640"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"serviceName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"liquidity.turnstile.eth"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"accepts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"scheme"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"exact"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"network"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"hedera:testnet"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"asset"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"80897110"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"payTo"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0.0.10403961"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"extra"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"symbol"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"HBAR"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"feePayer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0.0.7162784"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"scheme"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"exact"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"network"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"eip155:5042002"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"asset"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0x3600…0000"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"70000"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"payTo"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0x0Adc…f5F2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"extra"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"GatewayWalletBatched"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"verifyingContract"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0x0077…19b9"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"scheme"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"exact"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"network"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"eip155:84532"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"asset"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0x036C…CF7e"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"70000"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"payTo"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0x0Adc…f5F2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"extra"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"USDC"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"scheme"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"exact"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"network"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"eip155:8453"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"asset"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0x8335…2913"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"70000"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"payTo"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0x0Adc…f5F2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"extra"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"USD Coin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All four entries ask for the same $0.07. On Hedera that's 80,897,110 tinybars, 0.809 HBAR at the rate the rail read from Hedera's mirror node. On the other three it's 70,000 units of USDC. Each &lt;code&gt;extra&lt;/code&gt; carries what a payer needs to sign for that chain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. The agent picks one and signs it.&lt;/strong&gt; It selects the entries it has a signer for and that its spending rules allow, then picks by preference and price. &lt;a href="https://ignaciopastorsanchez.com/blog/privy-spending-mandates-key-quorums" rel="noopener noreferrer"&gt;Part 7&lt;/a&gt; covers the rules Turnstile's buyer uses. It retries the same request with a &lt;code&gt;PAYMENT-SIGNATURE&lt;/code&gt; header, whose payload holds the signature and &lt;code&gt;accepted&lt;/code&gt;, a copy of the entry it chose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. The seller routes, verifies, works and settles.&lt;/strong&gt; The scheme and network in &lt;code&gt;accepted&lt;/code&gt; tell the seller (our server) which rail to hand the payment to. The answer comes back as a 200, with the receipt in a &lt;code&gt;PAYMENT-RESPONSE&lt;/code&gt; header.&lt;/p&gt;

&lt;p&gt;The rest of this article is the seller's side of steps 2 and 4: how one service builds that list from four chains, and routes each payment back without knowing which chain it was.&lt;/p&gt;

&lt;h2&gt;
  
  
  One seller, four settlement stacks
&lt;/h2&gt;

&lt;p&gt;The v2 spec splits the protocol into three layers: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;types&lt;/strong&gt; (&lt;code&gt;PaymentRequired&lt;/code&gt;, &lt;code&gt;PaymentPayload&lt;/code&gt;, the settlement response) are the same everywhere. &lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;logic&lt;/strong&gt; depends on two things: the &lt;strong&gt;scheme&lt;/strong&gt;, which says what kind of payment it is (&lt;code&gt;exact&lt;/code&gt; means "pay this precise amount") and the &lt;strong&gt;network&lt;/strong&gt;, which says where it settles, named by a CAIP-2 id such as &lt;code&gt;eip155:8453&lt;/code&gt; for Base.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;transport&lt;/strong&gt; is how the types travel; over HTTP, they ride in the headers above.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The seller rarely touches a chain itself. It hands the signed payment to a &lt;strong&gt;facilitator&lt;/strong&gt;, "a service that handles payment verification and blockchain settlement". A facilitator exposes three endpoints: &lt;code&gt;/verify&lt;/code&gt; checks a payment without moving money, &lt;code&gt;/settle&lt;/code&gt; submits it onchain, and &lt;code&gt;/supported&lt;/code&gt; lists the scheme and network pairs it handles.&lt;/p&gt;

&lt;p&gt;That sounds like chain-agnosticism for free. Below the message format, our four rails share almost nothing:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Rail&lt;/th&gt;
&lt;th&gt;Network&lt;/th&gt;
&lt;th&gt;How a payment works&lt;/th&gt;
&lt;th&gt;Facilitator&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;hedera-x402&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;hedera:testnet&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Payer part-signs a transfer naming the facilitator as fee payer; facilitator co-signs&lt;/td&gt;
&lt;td&gt;Blocky402&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;arc-usdc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;eip155:5042002&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;EIP-3009 authorization against Circle's GatewayWallet, spending a pre-deposited balance; Circle batches settlement&lt;/td&gt;
&lt;td&gt;Circle Gateway&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;base-usdc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;eip155:84532&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;EIP-3009 authorization against the USDC contract; the facilitator submits one &lt;code&gt;transferWithAuthorization&lt;/code&gt; per payment&lt;/td&gt;
&lt;td&gt;x402.org&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;base-usdc-mainnet&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;eip155:8453&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Same code as &lt;code&gt;base-usdc&lt;/code&gt;, with mainnet's chain id, USDC address and EIP-712 name&lt;/td&gt;
&lt;td&gt;PayAI&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Hedera needs an FX rate, Arc credits a Gateway balance, Base needs the token's EIP-712 domain in the challenge. &lt;/p&gt;

&lt;p&gt;The route handler is the code that issues the 402, checks the payment and decides whether the answer goes out. If it handled the implementation details for payments itself, with an &lt;code&gt;if hedera&lt;/code&gt; here and an &lt;code&gt;if base&lt;/code&gt; there, every new chain would mean editing the code that takes money, and risking a bug in the payments that already work. So each chain's details live in its own rail, a module under &lt;code&gt;rails/&lt;/code&gt;, and the handler talks to every rail through the same four methods. &lt;/p&gt;

&lt;p&gt;(The first two rails have their own write-ups: &lt;a href="https://ignaciopastorsanchez.com/blog/x402-on-hedera-blocky402-paid-http" rel="noopener noreferrer"&gt;x402 on Hedera with Blocky402&lt;/a&gt; and &lt;a href="https://ignaciopastorsanchez.com/blog/gasless-nanopayments-eip3009-circle-gateway-arc" rel="noopener noreferrer"&gt;gasless nanopayments on Arc&lt;/a&gt;.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Four methods between the service and the chain
&lt;/h2&gt;

&lt;p&gt;The rule at the top of &lt;code&gt;rails/PaymentRail.ts&lt;/code&gt;: &lt;strong&gt;the service speaks US dollars, the rail speaks chains.&lt;/strong&gt; The service asks for a price in dollars. The rail converts it to the asset's smallest unit (tinybars on Hedera, at the current HBAR rate; USDC's six-decimal units on Arc and Base, so $0.07 is &lt;code&gt;70000&lt;/code&gt;), names its payout account in its own format, and puts everything chain-specific into &lt;code&gt;extra&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;The service builds the 402 response. It copies each rail's network id, payout address and &lt;code&gt;extra&lt;/code&gt; into it without reading them. Routing a payment is a lookup: the registry keys each rail by the scheme and network it declares, and finds the one the payer signed for. Nothing in the service tests for a particular chain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;ChallengeRequest&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;priceUsd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;maxTimeoutSeconds&lt;/span&gt;&lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;PaymentRequirement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;scheme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;NetworkId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;payTo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;maxTimeoutSeconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;extra&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;unknown&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;PaymentRail&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RailInfo&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;challenge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ChallengeRequest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;PaymentRequirement&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;verify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;PaymentPayload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="nc"&gt;VerifyContext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;VerifyResult&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;settle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;PaymentPayload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Receipt&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;receipt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Receipt&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/rails/PaymentRail.ts" rel="noopener noreferrer"&gt;&lt;code&gt;rails/PaymentRail.ts&lt;/code&gt;&lt;/a&gt;, trimmed, comments removed&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Three choices in that interface. The types are structurally x402 v2's but declared locally, so an SDK upgrade can't silently change the interface; a test validates them against the SDK's schema. All four methods are async, because Hedera needs a rate and Base checks &lt;code&gt;/supported&lt;/code&gt; before quoting. And &lt;code&gt;verify&lt;/code&gt; returns a reason code (&lt;code&gt;insufficient_funds&lt;/code&gt;, &lt;code&gt;unsupported_rail&lt;/code&gt;, &lt;code&gt;expired&lt;/code&gt;...) rather than a boolean, because the buyer does something different for each. A bad payment becomes a 402; a rail that can't answer throws &lt;code&gt;PaymentRailError&lt;/code&gt; and becomes a 503.&lt;/p&gt;

&lt;h2&gt;
  
  
  The registry: rails in, &lt;code&gt;accepts[]&lt;/code&gt; out
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rails&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nc"&gt;PaymentRail&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rails&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'a seller with no payment rails can never be paid; pass at least one'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;rail&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;rails&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rail&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scheme&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rail&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;clash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;byKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clash&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sb"&gt;`rails '${clash.id}' and '${rail.id}' both claim scheme ${rail.info.scheme} on ${rail.info.network}; `&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
        &lt;span class="s1"&gt;'a payment naming that pair would be unroutable'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;challengeAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ChallengeRequest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;settled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;allSettled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rails&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rail&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;rail&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;challenge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;accepts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;PaymentRequirement&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;failed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;railId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;settled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;rail&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rails&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'fulfilled'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;accepts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;failed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;railId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rail&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reason&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;accepts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;failed&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/rails/registry.ts" rel="noopener noreferrer"&gt;&lt;code&gt;rails/registry.ts&lt;/code&gt;&lt;/a&gt;, trimmed&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Routing is by &lt;code&gt;(scheme, network)&lt;/code&gt; because that is what each signed payment names. The payer picks the rail by choosing which entry to sign. If two rails declared the same scheme and network, say Base mainnet through two different facilitators, a signed payment couldn't say which one it was for. So the registry refuses to start when two rails share the same network and schema. &lt;/p&gt;

&lt;p&gt;A rail that can't quote is dropped instead of failing the request; only when everything fails does the service return 503. The composition root, &lt;code&gt;server.ts&lt;/code&gt;, is the one place that names concrete rails: &lt;code&gt;new RailRegistry([createHederaRail(), createArcRail(), createBaseRail(), createBaseMainnetRail()])&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The live 402 lists &lt;code&gt;hedera:testnet&lt;/code&gt;, &lt;code&gt;eip155:5042002&lt;/code&gt;, &lt;code&gt;eip155:84532&lt;/code&gt; and &lt;code&gt;eip155:8453&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not the SDK's resource-server middleware
&lt;/h2&gt;

&lt;p&gt;The payment headers are encoded and validated with &lt;code&gt;@x402/core&lt;/code&gt;, the official SDK, so any x402 client can read them. The middleware around them, about 120 lines, is ours. &lt;/p&gt;

&lt;p&gt;The SDK's middleware checks a payment against the route it's paying for, so it would stop a $0.07 payment buying the $0.35 tier too. We wrote our own for two other reasons.&lt;/p&gt;

&lt;p&gt;First, the SDK's middleware drives its own plug-ins: a scheme server per network that prices each challenge (&lt;code&gt;parsePrice&lt;/code&gt;, &lt;code&gt;enhancePaymentRequirements&lt;/code&gt; and several optional hooks), and a facilitator client it calls to verify and settle. Each rail would have been split across those two, in the SDK's order, instead of being one object with four methods.&lt;/p&gt;

&lt;p&gt;Second, it requires the payment's amount to equal a fresh quote exactly. The Hedera rail prices in HBAR at the current rate, so if the rate moves between the 402 and the payment, the fresh quote changes, and an honest payment would be refused.&lt;/p&gt;

&lt;p&gt;So on a paid request, &lt;code&gt;x402.ts&lt;/code&gt; re-issues the challenge for the URL requested and checks the payer's chosen entry against it: same &lt;code&gt;(scheme, network)&lt;/code&gt;, &lt;code&gt;asset&lt;/code&gt; and &lt;code&gt;payTo&lt;/code&gt;, and &lt;code&gt;amount &amp;gt;= quoted&lt;/code&gt;. The &lt;code&gt;&amp;gt;=&lt;/code&gt; tolerates HBAR moving between quote and payment, and is safe in the direction that matters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'a payment issued for the cheap tier cannot buy the premium one'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;withServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;app&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;baseUrl&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cheap&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;challengeFor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;baseUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sb"&gt;`/analyze/${POOL}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${baseUrl}/analyze/${POOL}/attested`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'PAYMENT-SIGNATURE'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cheap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;accepts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;402&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nc"&gt;PaymentRequiredBody&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;below&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;quoted&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt; &lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BigInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;accepts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;BigInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cheap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;accepts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/seller/service/x402.test.ts" rel="noopener noreferrer"&gt;&lt;code&gt;seller/service/x402.test.ts&lt;/code&gt;&lt;/a&gt;, comments removed&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;One caveat: rails also write &lt;code&gt;extra.resource&lt;/code&gt; and compare it in &lt;code&gt;verify()&lt;/code&gt;, but that is advisory. An EIP-3009 authorization commits to &lt;code&gt;from&lt;/code&gt;, &lt;code&gt;to&lt;/code&gt;, &lt;code&gt;value&lt;/code&gt;, the validity window and &lt;code&gt;nonce&lt;/code&gt;, not to a URL, so a payer can edit it. What holds is the service's fresh amount check plus each rail's replay guard (keyed on &lt;code&gt;from:nonce&lt;/code&gt; on EVM).&lt;/p&gt;

&lt;p&gt;The risk of custom middleware is speaking an x402 dialect only our client understands. &lt;code&gt;x402-interop.test.ts&lt;/code&gt; covers it: the 402 must pass the SDK's &lt;code&gt;validatePaymentRequired&lt;/code&gt;, and an unmodified &lt;code&gt;@x402/fetch&lt;/code&gt; client must complete the flow and get a 200.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verify, then work, then settle, and who takes the loss
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;verified&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;valid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;challenge&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sb"&gt;`payment rejected by ${rail.id}: ${verified.reason ?? 'unknown'}`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;sendChallenge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;challenge&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;receipt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Receipt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;receipt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;rail&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;settle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cause&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;402&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`settlement failed on ${rail.id}: ${cause instanceof Error ? cause.message : String(cause)}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;x402Version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;X402_VERSION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;accepts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;receipt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;success&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;402&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`settlement failed on ${rail.id}: ${receipt.error ?? 'unknown'}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;x402Version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;X402_VERSION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;accepts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'PAYMENT-RESPONSE'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;encodePaymentResponseHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;receiptToSettleResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;receipt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;never&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/seller/service/x402.ts" rel="noopener noreferrer"&gt;&lt;code&gt;seller/service/x402.ts&lt;/code&gt;&lt;/a&gt;, trimmed (rejection detail and cache header omitted)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If the process fails, then who pays for the cost?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Bad payment:&lt;/strong&gt; refused before any work. Nobody loses.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Handler throws&lt;/strong&gt; (subgraph down, bad pool address): no value moved, so the payer isn't charged. We lose the compute.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Settlement fails after the work:&lt;/strong&gt; the answer is withheld and the buyer gets a 402 and can retry. We lose the cost of compute, rather than giving the answer away.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is what the 402 v2 spec calls the default &lt;code&gt;authorization&lt;/code&gt; flow, "verify → resource → settle → respond", where "funds move only after it completes successfully". The spec also defines &lt;code&gt;upfront&lt;/code&gt; and &lt;code&gt;escrow&lt;/code&gt; flows that settle before the resource runs; which one applies is a property of the scheme. Rails report a refused settlement as &lt;code&gt;{ success: false, error }&lt;/code&gt; rather than throwing. Not getting paid is an expected outcome with a reason, such as the payer's balance having moved since verify, and the service passes that reason to the buyer in the 402. A thrown error gets the same 402, for failures a rail didn't anticipate.&lt;/p&gt;

&lt;h2&gt;
  
  
  A test that keeps chains out of the payment code
&lt;/h2&gt;

&lt;p&gt;The seller is three folders. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;seller/analyst/&lt;/code&gt; does the work: it queries the Uniswap subgraph and scores the pool.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;rails/&lt;/code&gt; holds one folder per chain. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;seller/service/&lt;/code&gt; sits between them: it serves the HTTP routes, sets the tier prices, runs the x402 middleware, and calls the analyst only once a payment checks out.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;seller/service/&lt;/code&gt; is the code that takes money, and it's chain-agnostic. Adding a chain means a new folder under &lt;code&gt;rails/&lt;/code&gt; and one line in &lt;code&gt;server.ts&lt;/code&gt; that adds the rail to the list. Keeping it that way makes easier to extend the system without turning the code into an endless stream of &lt;code&gt;if-else&lt;/code&gt; statements. For example, Hedera and Arc were built at the same time, and each had a shortcut available: a small &lt;code&gt;if&lt;/code&gt; in the service, a Hedera-shaped field on the challenge, a special case for how Arc reports a payer. Each looks harmless. Together they put chain logic back in the payment code, and the next chain would mean editing it again.&lt;/p&gt;

&lt;p&gt;So the rule is a test, and a change that breaks it fails the build instead of relying on someone to spot it in review. The test reads every TypeScript file in &lt;code&gt;seller/service/&lt;/code&gt;, strips the comments, and fails if the code names a chain, a facilitator, an asset or a signature format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;FORBIDDEN&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;RegExp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;term&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'hedera'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'a chain'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;term&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'blocky402'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'a facilitator'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;term&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'arc'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'a chain'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;term&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'usdc'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'an asset'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;term&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'eip155'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'a chain namespace'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;term&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'viem'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'a chain library'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;term&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'chainId'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'a chain identifier'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;term&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'privateKey'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'a chain key'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="n"&gt;beip&lt;/span&gt;&lt;span class="o"&gt;-?&lt;/span&gt;&lt;span class="mi"&gt;712&lt;/span&gt;\&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'a signature format'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="n"&gt;beip&lt;/span&gt;&lt;span class="o"&gt;-?&lt;/span&gt;&lt;span class="mi"&gt;3009&lt;/span&gt;\&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'a transfer authorization format'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/seller/service/no-chain-code.test.ts" rel="noopener noreferrer"&gt;&lt;code&gt;seller/service/no-chain-code.test.ts&lt;/code&gt;&lt;/a&gt;, trimmed&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;term()&lt;/code&gt; matches a name inside camelCase too, so &lt;code&gt;payload.hederaTransaction&lt;/code&gt; fails the test, while &lt;code&gt;arcane&lt;/code&gt; and &lt;code&gt;circles&lt;/code&gt; pass. The test also checks imports. Only &lt;code&gt;server.ts&lt;/code&gt;, which wires the rails together at startup, may import a concrete rail, and &lt;code&gt;x402.ts&lt;/code&gt; may import only the interface and the registry from &lt;code&gt;rails/&lt;/code&gt;. A few files are exempt by name, such as &lt;code&gt;server.ts&lt;/code&gt; and the discovery module, whose job is reading a multi-chain registry. Any new file is checked by default.&lt;/p&gt;

&lt;p&gt;The test matches names, so chain logic written in neutral words would get through. It was enough: when Base landed, two chains touched &lt;code&gt;rails/base-usdc/&lt;/code&gt; and one line of &lt;code&gt;server.ts&lt;/code&gt;, and nothing on the payment path.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding Base: two rails, one implementation
&lt;/h2&gt;

&lt;p&gt;Base is where x402 started, since Coinbase created the protocol, so it gets two rails: Sepolia for testing and mainnet for real money.&lt;/p&gt;

&lt;p&gt;On EVM, x402's &lt;code&gt;exact&lt;/code&gt; scheme defaults to EIP-3009: the payer signs &lt;code&gt;TransferWithAuthorization&lt;/code&gt; against the token's EIP-712 domain, and the facilitator calls &lt;code&gt;transferWithAuthorization&lt;/code&gt;. EIP-3009 lets users "delegate the gas payment to someone else", so the payer needs only USDC. The scheme spec makes &lt;code&gt;extra.name&lt;/code&gt; and &lt;code&gt;extra.version&lt;/code&gt; required in the challenge.&lt;/p&gt;

&lt;p&gt;Every difference between the chains was a constant, so mainnet just needs to get a second instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;MAINNET_NETWORK&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'eip155:8453'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;MAINNET_CHAIN_ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;8453&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;MAINNET_USDC_ASSET&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;MAINNET_EIP712_NAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'USD Coin'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;MAINNET_FACILITATOR_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'https://facilitator.payai.network'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createBaseMainnetRail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;BaseRailOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;PaymentRail&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;createBaseRail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'base-usdc-mainnet'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;chainLabel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Base'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;MAINNET_NETWORK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;MAINNET_USDC_ASSET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;eip712Name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;MAINNET_EIP712_NAME&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;facilitatorUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;MAINNET_FACILITATOR_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;rpcUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;MAINNET_RPC_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/rails/base-usdc/config.ts" rel="noopener noreferrer"&gt;&lt;code&gt;rails/base-usdc/config.ts&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/rails/base-usdc/index.ts" rel="noopener noreferrer"&gt;&lt;code&gt;rails/base-usdc/index.ts&lt;/code&gt;&lt;/a&gt;, trimmed&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The x402.org facilitator only lists Base Sepolia, so mainnet goes through &lt;a href="https://payai.network/" rel="noopener noreferrer"&gt;PayAI&lt;/a&gt;, whose &lt;code&gt;/supported&lt;/code&gt; lists &lt;code&gt;exact&lt;/code&gt; on &lt;code&gt;eip155:8453&lt;/code&gt; and needs no API key. Two details matter when you sign for Base.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;resource&lt;/code&gt; is an object.&lt;/strong&gt; In x402 v2, a 402 describes what's for sale in a &lt;code&gt;resource&lt;/code&gt; object. It has a required &lt;code&gt;url&lt;/code&gt; and optional fields that catalogues use for discovery: &lt;code&gt;description&lt;/code&gt;, &lt;code&gt;mimeType&lt;/code&gt;, &lt;code&gt;serviceName&lt;/code&gt;, &lt;code&gt;tags&lt;/code&gt; and &lt;code&gt;iconUrl&lt;/code&gt;. Turnstile's 402 sends the URL, a one-line description, &lt;code&gt;application/json&lt;/code&gt;, and &lt;code&gt;liquidity.turnstile.eth&lt;/code&gt; as the service name. The payer can echo the object back in its payment, and PayAI checks its shape, so a plain URL string there is rejected.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"USD Coin" is not "USDC".&lt;/strong&gt; A payer signs &lt;code&gt;TransferWithAuthorization&lt;/code&gt; against the token's EIP-712 domain, four fields that tie a signature to one contract on one chain. For Circle's USDC on Base:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Base mainnet&lt;/th&gt;
&lt;th&gt;Base Sepolia&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"USD Coin"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"USDC"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;version&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"2"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"2"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;chainId&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;8453&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;84532&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;verifyingContract&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0x8335…2913&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0x036C…CF7e&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The payer takes them from the 402: &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;version&lt;/code&gt; from the entry's &lt;code&gt;extra&lt;/code&gt;, &lt;code&gt;chainId&lt;/code&gt; from &lt;code&gt;network&lt;/code&gt;, and the contract from &lt;code&gt;asset&lt;/code&gt;. USDC doesn't expose its domain through EIP-5267's &lt;code&gt;eip712Domain()&lt;/code&gt;, so each Base rail sets these in its config, as read from the contract's &lt;code&gt;name()&lt;/code&gt; and &lt;code&gt;version()&lt;/code&gt;. Hashing the four fields reproduces the contract's &lt;code&gt;DOMAIN_SEPARATOR()&lt;/code&gt; on both chains.&lt;/p&gt;

&lt;p&gt;Get one field wrong and the signature is valid, but over the wrong domain. The facilitator answers &lt;code&gt;invalid_exact_evm_signature&lt;/code&gt;, the same error as a bad key. A test pins &lt;code&gt;extra.name === 'USD Coin'&lt;/code&gt; and &lt;code&gt;chainId === 8453&lt;/code&gt; for mainnet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Selling through a gateway that collects the payment
&lt;/h2&gt;

&lt;p&gt;Turnstile also sells through &lt;a href="https://bazantic.com" rel="noopener noreferrer"&gt;Bazantic&lt;/a&gt;, which we used as a distribution channel. Bazantic is a marketplace for paid APIs: a provider lists an API behind Bazantic's gateway, and agents find it in the catalogue and pay per call with the &lt;code&gt;baz&lt;/code&gt; CLI or through the gateway's MCP endpoint, from a balance they already hold with Bazantic. Those buyers never see Turnstile's 402 or pick a rail.&lt;/p&gt;

&lt;p&gt;Bazantic's gateway "sits in front, handles x402/MPP settlement, and forwards each call to the backend", and pays out to a receiving address set on the listing. Toward the backend it authenticates with an API key, basic auth or nothing, plus any extra headers. It never pays the backend's own 402.&lt;/p&gt;

&lt;p&gt;Without anything else, every call through Bazantic would hit two paywalls. The buyer pays Bazantic, Bazantic forwards the call with no payment attached, and Turnstile answers it with its own 402. So the seller (our server) has to recognise a call that Bazantic has already been paid for. The listing sends a shared secret in a header, and the seller checks it before asking any rail for a quote:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;gateway&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gateways&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;identify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;GATEWAY_KEY_HEADER&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gateway&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'X-Turnstile-Settled-By'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gateway&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Cache-Control'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'no-store'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/IpastorSan/turnstile/blob/main/seller/service/x402.ts" rel="noopener noreferrer"&gt;&lt;code&gt;seller/service/x402.ts&lt;/code&gt;&lt;/a&gt;, trimmed (logging omitted); key parsing in &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/seller/service/gateway.ts" rel="noopener noreferrer"&gt;&lt;code&gt;seller/service/gateway.ts&lt;/code&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The secret rides in &lt;code&gt;x-turnstile-gateway-key&lt;/code&gt;, set as an extra header on the listing. &lt;code&gt;gateway.ts&lt;/code&gt; refuses to boot on a malformed pair or a key under 32 characters, so a typo closes the seller instead of opening it, and compares SHA-256 digests with &lt;code&gt;timingSafeEqual&lt;/code&gt;. A wrong or missing key gets the normal 402. The key is the trust you give any reseller. Bazantic, or anyone who got the key from it, gets answers without paying Turnstile. The key lives only in Turnstile's environment and on the listing, and changing it in both places revokes it. Payment for those calls shows up as Bazantic's payout to the listing's address, not as x402 receipts at the seller.&lt;/p&gt;

&lt;p&gt;The architecture point: x402 composes when each hop settles its own payment, and breaks when one party settles on another's behalf. A service that never knows how it was paid still needs a third answer besides "paid here" and "unpaid": "paid somewhere I trust".&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/coinbase/x402/blob/main/specs/x402-specification-v2.md" rel="noopener noreferrer"&gt;x402 specification v2&lt;/a&gt;: layers, facilitator &lt;code&gt;/verify&lt;/code&gt; and &lt;code&gt;/settle&lt;/code&gt;, &lt;code&gt;ResourceInfo&lt;/code&gt; objects, and the &lt;code&gt;authorization&lt;/code&gt;/&lt;code&gt;upfront&lt;/code&gt;/&lt;code&gt;escrow&lt;/code&gt; flows.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/coinbase/x402/blob/main/specs/transports-v2/http.md" rel="noopener noreferrer"&gt;x402 HTTP transport v2&lt;/a&gt;: the &lt;code&gt;PAYMENT-REQUIRED&lt;/code&gt;, &lt;code&gt;PAYMENT-SIGNATURE&lt;/code&gt; and &lt;code&gt;PAYMENT-RESPONSE&lt;/code&gt; headers.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/coinbase/x402/blob/main/specs/schemes/exact/scheme_exact_evm.md" rel="noopener noreferrer"&gt;x402 &lt;code&gt;exact&lt;/code&gt; scheme on EVM&lt;/a&gt;: EIP-3009 by default, &lt;code&gt;extra.name&lt;/code&gt; and &lt;code&gt;extra.version&lt;/code&gt; required.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.x402.org" rel="noopener noreferrer"&gt;x402.org&lt;/a&gt;: "an open, neutral standard for internet-native payments".&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://eips.ethereum.org/EIPS/eip-712" rel="noopener noreferrer"&gt;EIP-712&lt;/a&gt;: &lt;code&gt;EIP712Domain&lt;/code&gt; fields and the domain separator's purpose.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://eips.ethereum.org/EIPS/eip-3009" rel="noopener noreferrer"&gt;EIP-3009&lt;/a&gt;: &lt;code&gt;transferWithAuthorization&lt;/code&gt;, random nonces, gas delegation.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developers.circle.com/stablecoins/usdc-contract-addresses" rel="noopener noreferrer"&gt;Circle USDC contract addresses&lt;/a&gt;: Base and Base Sepolia USDC, matching &lt;code&gt;config.ts&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://facilitator.payai.network/supported" rel="noopener noreferrer"&gt;PayAI &lt;code&gt;/supported&lt;/code&gt;&lt;/a&gt;: lists &lt;code&gt;exact&lt;/code&gt; on &lt;code&gt;eip155:8453&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.payai.network/x402/facilitators/pricing.md" rel="noopener noreferrer"&gt;PayAI facilitator pricing&lt;/a&gt;: free tier and per-settlement pricing as PayAI states it.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://bazantic.com/docs/deploy-a-gateway" rel="noopener noreferrer"&gt;Bazantic: Deploy a gateway&lt;/a&gt; and &lt;a href="https://bazantic.com/llms.txt" rel="noopener noreferrer"&gt;llms.txt&lt;/a&gt;: the authentication-method wording; production gateways settle USDC on Base.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://basescan.org/tx/0xf1088b77d72de2daea61f6c6f48d1da508c227e8f556b09355b38dd3d2c3919f" rel="noopener noreferrer"&gt;Base tx 0xf1088b77…919f&lt;/a&gt;: the $0.07 gateway payment.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Turnstile repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Next in the series:&lt;/strong&gt; &lt;a href="https://ignaciopastorsanchez.com/blog/erc8004-agent-discovery-substreams" rel="noopener noreferrer"&gt;A sample of 197 ERC-8004 agents, and where their prices live&lt;/a&gt;, part 4 of 9.&lt;/p&gt;

</description>
      <category>web3</category>
      <category>typescript</category>
      <category>ai</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Gasless nanopayments on Arc, and the nonce that stays at 0</title>
      <dc:creator>Ignacio Pastor Sánchez</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:36:06 +0000</pubDate>
      <link>https://dev.to/ignacio_pastor/gasless-nanopayments-on-arc-and-the-nonce-that-stays-at-0-29ne</link>
      <guid>https://dev.to/ignacio_pastor/gasless-nanopayments-on-arc-and-the-nonce-that-stays-at-0-29ne</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 2 of 9 in the &lt;a href="https://ignaciopastorsanchez.com/blog/series/turnstile" rel="noopener noreferrer"&gt;Turnstile series&lt;/a&gt;: building a paid lane for onchain data agents.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;I built &lt;a href="https://ignaciopastorsanchez.com/blog/turnstile-overview" rel="noopener noreferrer"&gt;&lt;strong&gt;Turnstile&lt;/strong&gt;&lt;/a&gt;, a paid lane for onchain data agents. A buyer agent asks a seller for an answer about a Uniswap pool, gets an HTTP 402, pays, and gets the answer. One of the payment rails runs on &lt;strong&gt;Arc testnet&lt;/strong&gt;, settled through &lt;strong&gt;Circle Gateway nanopayments&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The property I wanted is simple to say: &lt;strong&gt;the agent that spends money should never pay gas.&lt;/strong&gt; Someone still pays, so this post follows each cost to whoever covers it, and ends with the one number on chain that shows it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The agent signs an &lt;strong&gt;EIP-3009 &lt;code&gt;TransferWithAuthorization&lt;/code&gt;&lt;/strong&gt; offchain. That is a signature, not a transaction. No transaction, no gas.&lt;/li&gt;
&lt;li&gt;Circle Gateway credits the seller immediately, then &lt;strong&gt;batches many authorizations into one onchain transaction&lt;/strong&gt;, submitted and paid for by Circle's batcher. The batching is what makes a $0.0005 payment make economic sense.&lt;/li&gt;
&lt;li&gt;The agent's spending balance is funded by a different wallet (the "warm tier") calling &lt;strong&gt;&lt;code&gt;depositFor(token, agent, value)&lt;/code&gt;&lt;/strong&gt;. The caller pays that gas; the agent receives the balance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Circle's batcher is the gas sponsor&lt;/strong&gt;, though not an ERC-4337 paymaster: there is no smart account and no EntryPoint. On Arc, &lt;strong&gt;USDC is also the native gas token&lt;/strong&gt;, so the agent's wallet holds 0 USDC on chain. Its spending money sits in Circle's GatewayWallet contract.&lt;/li&gt;
&lt;li&gt;The seller is credited inside Gateway and pays gas only when it withdraws to its own wallet.&lt;/li&gt;
&lt;li&gt;After &lt;strong&gt;eleven settled payments&lt;/strong&gt;, the agent's &lt;code&gt;eth_getTransactionCount&lt;/code&gt; is still &lt;strong&gt;0&lt;/strong&gt;. It has never sent a transaction, so it has never paid a wei of gas.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The code is on &lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Github&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  An agent with a wallet
&lt;/h2&gt;

&lt;p&gt;Turnstile is a market where AI agents buy answers or data from other agents. The seller in this series answers one question about a Uniswap pool, "is it safe to LP?", for $0.07 a query, or $0.35 for a premium answer that includes the evidence behind the verdict. The buyer is an agent too: it finds the seller, gets a &lt;code&gt;402 Payment Required&lt;/code&gt; with the price, pays, and gets the answer, with no human in the loop.&lt;/p&gt;

&lt;p&gt;That makes the buyer an agent with a wallet, and two things about it are uncomfortable.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Agents that pay per call push prices toward fractions of a cent, and a sub-cent payment could be smaller than the gas it would take to send it.&lt;/li&gt;
&lt;li&gt;The agent's wallet private key sits next to an LLM loop, a program that decides what to do from text it reads. You want to be able to control that key so it can only pay for queries and nothing else.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This post shows how Turnstile's Arc rail solves both. The agent never sends a transaction. It signs it without broadcasting it, and Circle Gateway collects the signatures and settles them in batches. Along the way you'll see where each bit of gas goes and who pays for it, and why one number on chain, the agent's nonce, shows the agent itself never paid any. &lt;/p&gt;

&lt;p&gt;If you're building agents that pay for things, Circle ships this on mainnet today, so you can use the same design.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fractions of a cent
&lt;/h2&gt;

&lt;p&gt;On Arc testnet, the deposit that funded the whole mandate cost &lt;strong&gt;0.0019 USDC&lt;/strong&gt; in gas. That is roughly four times the price of one $0.0005 query.&lt;/p&gt;

&lt;p&gt;Turnstile's seller sells a verdict on a liquidity pool, at $0.07 for the standard tier. The demo also runs the same query at $0.0005, because sub-cent pricing is where agent-to-agent commerce gets interesting: an agent that calls a data service a few hundred times an hour does not want a card network, and it does not want to pay a transaction fee per call. Two constraints fall out of that.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A payment smaller than its transaction fee isn't worth settling on its own.&lt;/strong&gt; Sending a $0.0005 payment when its own transaction costs about four times the payment in gas, would make someone lose money on every query.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The key that spends should have as few permissions as possible.&lt;/strong&gt; Turnstile has a cold/warm/hot key hierarchy, and its invariant is &lt;em&gt;the key that spends can never raise its own limit&lt;/em&gt;. If the hot key can send arbitrary transactions, it ould do much more than pay for queries.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The first constraint says "batch". The second says the agent should hold no gas and send no transactions, so the only money it can ever move is what the org deposited for it, under a cap the agent can't change. One mechanism gives you both.&lt;/p&gt;

&lt;p&gt;Where that money can go is the mandate's job. Before signing anything, the agent's payment code checks the 402 against the mandate, and refuses to pay to any seller the mandate doesn't name or any price above its per-query ceiling. &lt;a href="https://ignaciopastorsanchez.com/blog/privy-spending-mandates-key-quorums" rel="noopener noreferrer"&gt;Part 7&lt;/a&gt; covers how the org issues that mandate.&lt;/p&gt;

&lt;h2&gt;
  
  
  EIP-3009: moving tokens with a signature
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://eips.ethereum.org/EIPS/eip-3009" rel="noopener noreferrer"&gt;EIP-3009&lt;/a&gt; (still in Draft status by the way, though USDC has shipped it for years) adds functions to an ERC-20 that let a token holder authorize a   transfer with an EIP-712 signature, and let &lt;em&gt;someone else&lt;/em&gt; execute it. Its motivation section is clear about why: it lets you "delegate the gas payment to someone else".&lt;/p&gt;

&lt;p&gt;The core function, from the spec:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// From the EIP-3009 specification (not Turnstile code)
function transferWithAuthorization(
    address from,
    address to,
    uint256 value,
    uint256 validAfter,
    uint256 validBefore,
    bytes32 nonce,
    uint8 v,
    bytes32 r,
    bytes32 s
) external;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The payer signs &lt;code&gt;(from, to, value, validAfter, validBefore, nonce)&lt;/code&gt;. Whoever holds that signature can call the function and pay the gas. Two details matter for agents.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The nonce is a random &lt;code&gt;bytes32&lt;/code&gt;, not a counter.&lt;/strong&gt; The spec argues sequential nonces make concurrent meta-transactions fragile, so an agent can sign many authorizations at once without them tripping over each other. It also means the EIP-3009 nonce has nothing to do with the account nonce at the end of this post. Different nonce, different layer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The signature commits to an exact &lt;code&gt;value&lt;/code&gt;.&lt;/strong&gt; You cannot redeem it for an amount different from the one the sender intends.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is what &lt;a href="https://github.com/coinbase/x402" rel="noopener noreferrer"&gt;x402&lt;/a&gt;'s &lt;code&gt;exact&lt;/code&gt; scheme does on EVM. The spec says the scheme "executes a transfer where the Facilitator (server) pays the gas, but the Client (user) controls the exact flow of funds via cryptographic signatures", and lists EIP-3009 as the recommended transfer method, "truly gasless". &lt;/p&gt;

&lt;p&gt;Settlement is the facilitator calling &lt;code&gt;transferWithAuthorization&lt;/code&gt; with the payload's signature. (Turnstile's other rail, on Hedera, has to do without EIP-3009 entirely; that story is in &lt;a href="https://ignaciopastorsanchez.com/blog/x402-on-hedera-blocky402-paid-http" rel="noopener noreferrer"&gt;x402 on Hedera&lt;/a&gt;.)&lt;/p&gt;

&lt;p&gt;So plain x402 on EVM already gives you a gasless payer. What it does not give you is batching: one authorization, one &lt;code&gt;transferWithAuthorization&lt;/code&gt; call, one transaction. A facilitator paying $0.0019 of gas to collect $0.0005 is still nonsense so we need a way to make this make economic sense.&lt;/p&gt;

&lt;h2&gt;
  
  
  Circle Gateway: same signature, different verifying contract
&lt;/h2&gt;

&lt;p&gt;Circle Gateway nanopayments keep the x402 &lt;code&gt;exact&lt;/code&gt; shape and change two things. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The authorization spends from a balance the payer deposited into Circle's GatewayWallet contract, rather than from the payer's wallet.&lt;/li&gt;
&lt;li&gt;Settlement is batched: Gateway credits the seller at once and settles many payments in one transaction later. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Circle's docs call it "gas-free USDC nanopayments down to $0.000001, powered by Circle Gateway batched settlement", where "buyers sign payment authorizations offchain at zero gas cost".&lt;/p&gt;

&lt;p&gt;Here is the flow as it ran in Turnstile.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The payer's balance lives in a contract.&lt;/strong&gt; USDC is deposited into Circle's &lt;strong&gt;GatewayWallet&lt;/strong&gt; contract once. That is an onchain transaction, and whoever deposits pays its gas. In Turnstile that is the buyer organization, not the agent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The authorization is signed against the GatewayWallet, not USDC.&lt;/strong&gt; The EIP-712 &lt;code&gt;verifyingContract&lt;/code&gt; in the 402 challenge is the GatewayWallet (&lt;code&gt;0x0077777d…19b9&lt;/code&gt; on Arc testnet), and the domain name is &lt;code&gt;GatewayWalletBatched&lt;/code&gt;. So a signature is a claim on a Gateway balance, not on a token allowance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The seller posts it to Gateway's &lt;code&gt;/v1/x402/settle&lt;/code&gt;.&lt;/strong&gt; Gateway credits the seller immediately and returns an &lt;strong&gt;authorization id&lt;/strong&gt;, which is a UUID, not a transaction hash.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Circle's batcher later redeems many authorizations in one transaction&lt;/strong&gt; against the GatewayWallet. The transaction's &lt;code&gt;from&lt;/code&gt; is Circle's batcher address, and the batcher pays its gas. No payer appears as a sender.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Step 2 deserves a second look. The seller's rail doesn't hardcode the verifying contract. It reads the EIP-712 domain from Gateway's own &lt;code&gt;/supported&lt;/code&gt; response on every quote, so if Circle redeploys the GatewayWallet, the new address reaches buyers with no code change. If &lt;code&gt;/supported&lt;/code&gt; stops giving a usable domain, the seller answers &lt;code&gt;503&lt;/code&gt; instead of quoting a payment that nobody could sign.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;scheme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'exact'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;usdToAtomic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;priceUsd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;decimals&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;payTo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;maxTimeoutSeconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;maxTimeoutSeconds&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="n"&gt;maxTimeoutSeconds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;extra&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// `name`, `version` and `verifyingContract` are the EIP-712 domain and&lt;/span&gt;
    &lt;span class="c1"&gt;// are not optional: a client cannot sign without them. Spread from the&lt;/span&gt;
    &lt;span class="c1"&gt;// facilitator's own answer rather than restated, so a redeploy on&lt;/span&gt;
    &lt;span class="c1"&gt;// Circle's side propagates without a code change here.&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kindExtra&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;facilitator&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;gateway&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;baseUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;settlementModel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'gateway-batched-authorization'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="n"&gt;settlementTiming&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'batched-asynchronous'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Trimmed from &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/rails/arc-usdc/index.ts" rel="noopener noreferrer"&gt;&lt;code&gt;rails/arc-usdc/index.ts&lt;/code&gt;&lt;/a&gt;, the Arc rail's &lt;code&gt;challenge()&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;On the buyer side there is almost nothing to write, which is the point. The agent's signer hands its key to Circle's own client scheme from &lt;a href="https://www.npmjs.com/package/@circle-fin/x402-batching" rel="noopener noreferrer"&gt;&lt;code&gt;@circle-fin/x402-batching&lt;/code&gt;&lt;/a&gt;, which builds and signs the EIP-3009 message for exactly the quoted amount:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;BatchEvmScheme&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@circle-fin/x402-batching/client'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;privateKeyToAccount&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'viem/accounts'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;account&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;privateKeyToAccount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rawKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'0x'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;rawKey&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`0x${rawKey}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nc"&gt;Hex&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;scheme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BatchEvmScheme&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;account&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;From &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/buyer/watchdog/arc-signer.ts" rel="noopener noreferrer"&gt;&lt;code&gt;buyer/watchdog/arc-signer.ts&lt;/code&gt;&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There is no wallet client and no RPC transport, nothing on the agent's side that &lt;em&gt;could&lt;/em&gt; send a transaction. The message itself is built and signed by Circle's &lt;code&gt;BatchEvmScheme&lt;/code&gt;. Circle runs the contract that verifies these signatures, so using its own encoder keeps the EIP-712 domain and fields exactly as the GatewayWallet expects.&lt;/p&gt;

&lt;h3&gt;
  
  
  What batching looked like on the chain
&lt;/h3&gt;

&lt;p&gt;Sampling 100 consecutive Gateway transfers on Arc testnet, they resolved to &lt;strong&gt;9 distinct transaction hashes&lt;/strong&gt;, 12 to 13 authorizations each.&lt;/p&gt;

&lt;p&gt;Turnstile's first run sent seven payments (one $0.07 query and six $0.0005 nanopayments), and all of them landed in a single transaction, &lt;a href="https://testnet.arcscan.app/tx/0xd6e77a59ad4740e5f89c9c601a05e7cf7859c9253fb1b3c31a8eae97e859a0c1" rel="noopener noreferrer"&gt;&lt;code&gt;0xd6e77a59…a0c1&lt;/code&gt;&lt;/a&gt;, in block 60940635. That transaction carried &lt;strong&gt;22 payments&lt;/strong&gt; in total, ours plus fifteen other Gateway users', moving 0.133111 USDC. A second run's four payments landed in &lt;a href="https://testnet.arcscan.app/tx/0xe50b8be63a2fe102c70de3b62a43251fbfcac1d8ca93f9f1760dd3c7a7985c39" rel="noopener noreferrer"&gt;&lt;code&gt;0xe50b8be6…5c39&lt;/code&gt;&lt;/a&gt;, block 60942503. So eleven payments went through only two transactions, both sent by Circle's batcher.&lt;/p&gt;

&lt;p&gt;Circle's batcher sends the batch transaction on its own schedule, so a Gateway payment has two moments. It is &lt;strong&gt;settled&lt;/strong&gt; when &lt;code&gt;/settle&lt;/code&gt; succeeds: Gateway credits the seller and debits the payer in its own balances, and Turnstile's seller then delivers the answer. &lt;/p&gt;

&lt;p&gt;The onchain transaction comes later, whenever the batcher sends it. That's why &lt;code&gt;/settle&lt;/code&gt; returns an authorization id, not a transaction hash.&lt;/p&gt;

&lt;h2&gt;
  
  
  Funding the agent without the agent: &lt;code&gt;depositFor&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;If the agent never transacts, how does it get a Gateway balance? Depositing into the GatewayWallet is a transaction, and the agent doesn't send transactions.&lt;/p&gt;

&lt;p&gt;The GatewayWallet has &lt;code&gt;depositFor(address token, address depositor, uint256 value)&lt;/code&gt;. Circle's contract reference describes it as depositing "on behalf of another address after approving this contract for the token. The resulting balance belongs to the address specified by the &lt;code&gt;depositor&lt;/code&gt; parameter, not the function caller."&lt;/p&gt;

&lt;p&gt;That one function is the whole key hierarchy. The &lt;strong&gt;warm tier&lt;/strong&gt; (the buyer organization's wallet) approves USDC, calls &lt;code&gt;depositFor&lt;/code&gt; naming the agent's address, and pays the gas. The &lt;strong&gt;hot tier&lt;/strong&gt; receives spending power but signs nothing onchain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;depositTxHash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;signAndSend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;gateway&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;encodeFunctionData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;abi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;DEPOSIT_FOR_ABI&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;functionName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'depositFor'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;usdc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;agentAddress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;nonce&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;gas_limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;hex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;DEPOSIT_GAS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Trimmed from &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/buyer/org/fund-agent.ts" rel="noopener noreferrer"&gt;&lt;code&gt;buyer/org/fund-agent.ts&lt;/code&gt;&lt;/a&gt;. &lt;code&gt;nonce&lt;/code&gt; here is the **org&lt;/em&gt;* wallet's nonce, which is expected to move.*&lt;/p&gt;

&lt;p&gt;Circle's nanopayments SDK reference documents a &lt;code&gt;deposit()&lt;/code&gt; method on the buyer's client, not &lt;code&gt;depositFor&lt;/code&gt;, so I call the contract function directly rather than through the SDK.&lt;/p&gt;

&lt;p&gt;The warm tier is a &lt;strong&gt;Privy server wallet&lt;/strong&gt; owned by an operations key quorum, with a policy (owned by a separate 2-of-2 board quorum) that pins &lt;code&gt;depositFor.depositor&lt;/code&gt; to the agent and caps &lt;code&gt;depositFor.value&lt;/code&gt;. Privy signs the transaction inside its enclave, and Turnstile broadcasts it to Arc's public RPC, because Privy does not route RPCs for Arc testnet. The details are in &lt;a href="https://ignaciopastorsanchez.com/blog/privy-spending-mandates-key-quorums" rel="noopener noreferrer"&gt;Spending mandates for agents&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A deposit transcript shows both sides of the hierarchy in one screen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;warm / org    0x3De96375140717193f52c220Df5Ec460971cbE84
  nonce       0 -&amp;gt; 2      (it transacts; this is expected to move)
  on chain    2.000000 -&amp;gt; 1.746664 USDC
hot / agent   0x0633a193017939Bb1eB242982397224c66948e2F
  nonce       0 -&amp;gt; 0      &amp;lt;-- the zero-gas proof
  on chain    0.000000 -&amp;gt; 0.000000 USDC   [native 0 wei]
  gateway     0.105500 -&amp;gt; 0.355500 USDC available
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The org's nonce moved by two (approve, deposit). The agent's did not, its onchain balance stayed zero, and its Gateway balance grew by exactly the deposit.&lt;/p&gt;

&lt;p&gt;One side effect. The hot key &lt;em&gt;cannot&lt;/em&gt; deposit, withdraw or widen its own allowance, because each of those is a transaction and it has no gas for sending one. So the invariant "the key that spends can never raise its own limit" holds even if the hot key tries to break it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who pays the gas
&lt;/h2&gt;

&lt;p&gt;Someone always pays. For the 402 payments themselves, it's Circle's batcher: it collects authorizations, submits one transaction per batch to the GatewayWallet, and pays its gas. In plain terms, the batcher is the gas sponsor.&lt;/p&gt;

&lt;p&gt;This isn't a testnet perk. Circle's &lt;a href="https://developers.circle.com/gateway/nanopayments" rel="noopener noreferrer"&gt;nanopayments docs&lt;/a&gt; describe the same terms on mainnet, where the product has been &lt;a href="https://www.quicknode.com/blog/nanopayments-powered-by-circle-gateway-live-on-mainnet-with-quicknode" rel="noopener noreferrer"&gt;live since April 2026&lt;/a&gt;: buyers "sign payment authorizations offchain at zero gas cost", and "neither party pays per-transaction fees". The docs don't name who pays for the batch transaction itself but on Arc testnet, every batch carrying Turnstile's payments was sent by Circle's batcher.&lt;/p&gt;

&lt;p&gt;It isn't a paymaster in the &lt;a href="https://eips.ethereum.org/EIPS/eip-4337" rel="noopener noreferrer"&gt;ERC-4337&lt;/a&gt; sense. There, a paymaster is "a helper contract that agrees to pay for the transaction, instead of the sender itself": the user has a smart account that executes an operation on chain, and the paymaster's deposit in the EntryPoint covers the gas. Turnstile's buyer agent has no smart account and executes nothing. It signs, and the batcher submits on its behalf, much like the facilitator in plain x402.&lt;/p&gt;

&lt;p&gt;The warm tier also pays gas so the agent doesn't have to, but only for its own transactions: one &lt;code&gt;approve&lt;/code&gt; and one &lt;code&gt;depositFor&lt;/code&gt;, up front. After that it never touches a payment. The job a paymaster does per operation is split in two: the org funds the agent once, and Circle's batcher pays gas on every settlement.&lt;/p&gt;

&lt;p&gt;Arc adds a twist. It "denominates all transaction fees in USDC, the native gas token", and the native balance (18 decimals) and the USDC ERC-20 interface (6 decimals) "share the same underlying balance". Measured on an org wallet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0xdFe3088aC34e7329006407C246C9F6D7534B2aC5
eth_getBalance   20000000000000000000   (18 dp) = 20.000000 USDC
USDC.balanceOf              20000000   ( 6 dp) = 20.000000 USDC
                 block 60938781, 2026-09-07T16:56:10Z
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So a wallet with no gas has no USDC either. Turnstile's buyer agent is exactly that, 0 wei and 0 USDC on chain, and it can still pay, because its spending money doesn't sit in its wallet. It sits in the GatewayWallet, credited to its address.&lt;/p&gt;

&lt;p&gt;Every cost in one place:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Who&lt;/th&gt;
&lt;th&gt;Pays&lt;/th&gt;
&lt;th&gt;When&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Org (warm tier)&lt;/td&gt;
&lt;td&gt;Gas for &lt;code&gt;approve&lt;/code&gt; and &lt;code&gt;depositFor&lt;/code&gt;, plus the USDC it deposits for the agent&lt;/td&gt;
&lt;td&gt;Once, to fund the agent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agent (hot tier)&lt;/td&gt;
&lt;td&gt;The quoted price, from its Gateway balance. No gas&lt;/td&gt;
&lt;td&gt;On every query&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Circle's batcher&lt;/td&gt;
&lt;td&gt;Gas for each batch transaction&lt;/td&gt;
&lt;td&gt;On every batch&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Seller&lt;/td&gt;
&lt;td&gt;Gas for &lt;code&gt;withdraw()&lt;/code&gt;, to move its Gateway balance on chain&lt;/td&gt;
&lt;td&gt;When it cashes out&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  A nonce that never moves
&lt;/h2&gt;

&lt;p&gt;My favourite part of this design is that you can see it from outside. &lt;code&gt;eth_getTransactionCount&lt;/code&gt; counts the transactions an account has sent. If it is 0, the account has never broadcast one, so it has never paid a wei of gas. A balance can't show the same thing, because a wallet can receive gas money and spend it back down to zero.&lt;/p&gt;

&lt;p&gt;The agent is &lt;a href="https://testnet.arcscan.app/address/0x0633a193017939Bb1eB242982397224c66948e2F" rel="noopener noreferrer"&gt;&lt;code&gt;0x0633a193017939Bb1eB242982397224c66948e2F&lt;/code&gt;&lt;/a&gt;. Read at a pinned block after all eleven payments had settled and both batches had mined:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;eth_getTransactionCount  0
eth_getBalance           0
USDC.balanceOf           0
                         block 60943091, 2026-09-07T17:33:02Z
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Meanwhile its Gateway balance went 0.25 to 0.1055 USDC across the eleven payments. And tin the meantime the seller's &lt;strong&gt;Gateway&lt;/strong&gt; balance read &lt;strong&gt;0.144500 USDC&lt;/strong&gt;, which reconciles exactly with what the buyer spent and with the eleven completed transfers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Avoid these pitfalls
&lt;/h2&gt;

&lt;p&gt;Four rough edges to know before you build on this, all observed on testnet..&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;exact&lt;/code&gt; means exact.&lt;/strong&gt; The buyer's signature commits to one amount, and a seller can't settle it for anything else. I signed one authorization for 70000 atomic units ($0.07) and asked Gateway's &lt;code&gt;/verify&lt;/code&gt; to check it against three prices: $0.07 passed (&lt;code&gt;isValid: true&lt;/code&gt;), and both $0.035 and $0.35 failed with &lt;code&gt;amount_mismatch&lt;/code&gt;. 
The reason is that EIP-3009 signs the &lt;code&gt;value&lt;/code&gt; along with the rest of the transfer, so a different amount is a different message, and the buyer never signed it. This basically kills fallback mechanisms like: if a seller finds it can't deliver what was paid for, say the premium answer, it can't charge less on the same signature. It has to refuse, send a new 402 with the new price, and let the buyer sign again. (x402 has a separate &lt;code&gt;upto&lt;/code&gt; scheme for amounts that vary; Gateway's nanopayments use &lt;code&gt;exact&lt;/code&gt;.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;/verify&lt;/code&gt; does not check the payer's balance.&lt;/strong&gt; An authorization from an empty Gateway balance verified clean and then failed &lt;code&gt;/settle&lt;/code&gt; with &lt;code&gt;insufficient_balance&lt;/code&gt;. An x402 seller that does its work between verify and settle (as the protocol intends) will do that work for nothing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The seller's payout wallet reads zero on a block explorer, and that is correct.&lt;/strong&gt; Gateway credits a &lt;em&gt;Gateway balance&lt;/em&gt;. Turning it into onchain USDC is a later &lt;code&gt;withdraw()&lt;/code&gt; the seller pays gas for. "Did they get paid?" checked on ArcScan returns a confident, wrong no.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Three names for one chain.&lt;/strong&gt; &lt;code&gt;eip155:5042002&lt;/code&gt; on the x402 wire, &lt;code&gt;arcTestnet&lt;/code&gt; in Circle's SDK, &lt;code&gt;domain: 26&lt;/code&gt; in the balances API.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  An agent that can only pay
&lt;/h2&gt;

&lt;p&gt;The intro asked two things of an agent with a wallet: pay amounts smaller than gas, and hold a key that can pay for queries and nothing else. Circle Gateway handles the first: the buyer signs, and Circle's batcher settles many payments in one transaction and pays the gas. Turnstile adds the rest. The org funds the agent with &lt;code&gt;depositFor&lt;/code&gt;, so the agent never needs gas to get started. &lt;/p&gt;

&lt;p&gt;The mandate decides whom it can pay and how much, and the agent has no client that could send a transaction. All it can do is sign for an exact amount, to a seller it's allowed to pay. How the org issues that mandate, and why raising its cap takes two signatures, is in &lt;a href="https://ignaciopastorsanchez.com/blog/privy-spending-mandates-key-quorums" rel="noopener noreferrer"&gt;Spending mandates for agents&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://eips.ethereum.org/EIPS/eip-3009" rel="noopener noreferrer"&gt;EIP-3009: Transfer With Authorization&lt;/a&gt;: the &lt;code&gt;transferWithAuthorization&lt;/code&gt; signature and typehash fields, random &lt;code&gt;bytes32&lt;/code&gt; nonces, delegating gas payment; status Draft.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://eips.ethereum.org/EIPS/eip-4337" rel="noopener noreferrer"&gt;ERC-4337: Account Abstraction Using Alt Mempool&lt;/a&gt;: definition of a paymaster as a contract that pays for the transaction instead of the sender, funded by a deposit in the EntryPoint.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/coinbase/x402/blob/main/specs/schemes/exact/scheme_exact_evm.md" rel="noopener noreferrer"&gt;x402 &lt;code&gt;exact&lt;/code&gt; scheme on EVM&lt;/a&gt;: the facilitator pays gas, EIP-3009 is the recommended "truly gasless" method, and settlement calls &lt;code&gt;transferWithAuthorization&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developers.circle.com/gateway/nanopayments" rel="noopener noreferrer"&gt;Circle Gateway nanopayments&lt;/a&gt;: gas-free USDC nanopayments, offchain buyer authorizations, batched settlement, no per-transaction fees for either party, one-time deposit into the Gateway Wallet.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.quicknode.com/blog/nanopayments-powered-by-circle-gateway-live-on-mainnet-with-quicknode" rel="noopener noreferrer"&gt;Nanopayments live on mainnet (Quicknode)&lt;/a&gt;: mainnet launch in April 2026 on Base, Polygon, Arbitrum and HyperEVM.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developers.circle.com/gateway/references/contract-interfaces-and-events" rel="noopener noreferrer"&gt;Circle Gateway contract interfaces and events&lt;/a&gt;: &lt;code&gt;depositFor(token, depositor, value)&lt;/code&gt; and that the balance belongs to &lt;code&gt;depositor&lt;/code&gt;, not the caller.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developers.circle.com/gateway/nanopayments/references/sdk" rel="noopener noreferrer"&gt;Circle nanopayments SDK reference&lt;/a&gt;: &lt;code&gt;deposit()&lt;/code&gt; is an onchain transaction that requires gas; &lt;code&gt;BatchEvmScheme&lt;/code&gt; signs an EIP-3009 &lt;code&gt;TransferWithAuthorization&lt;/code&gt;; &lt;code&gt;BatchFacilitatorClient&lt;/code&gt; talks to Gateway's x402 endpoints.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.arc.io/arc/concepts/stable-fee-design" rel="noopener noreferrer"&gt;Arc: stable fee design&lt;/a&gt;: relayers, paymasters and funded accounts on Arc must hold USDC, the native token.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.arc.io/arc/references/gas-and-fees" rel="noopener noreferrer"&gt;Arc: gas and fees&lt;/a&gt;: fees denominated in USDC as the native gas token; 18-decimal native accounting and 6-decimal ERC-20 interface share one balance.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Next in the series:&lt;/strong&gt; &lt;a href="https://ignaciopastorsanchez.com/blog/chain-agnostic-x402-seller-payment-rails" rel="noopener noreferrer"&gt;One payment interface, four chains&lt;/a&gt;, part 3 of 9.&lt;/p&gt;

</description>
      <category>ethereum</category>
      <category>web3</category>
      <category>ai</category>
      <category>agents</category>
    </item>
    <item>
      <title>x402 on Hedera: what a paid HTTP request is made of</title>
      <dc:creator>Ignacio Pastor Sánchez</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:35:42 +0000</pubDate>
      <link>https://dev.to/ignacio_pastor/x402-on-hedera-what-a-paid-http-request-is-made-of-2dmn</link>
      <guid>https://dev.to/ignacio_pastor/x402-on-hedera-what-a-paid-http-request-is-made-of-2dmn</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 1 of 9 in the &lt;a href="https://ignaciopastorsanchez.com/blog/series/turnstile" rel="noopener noreferrer"&gt;Turnstile series&lt;/a&gt;: building a paid lane for onchain data agents.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;I built &lt;a href="https://ignaciopastorsanchez.com/blog/turnstile-overview" rel="noopener noreferrer"&gt;Turnstile&lt;/a&gt; for ETHOnline 2026. Turnstile is a paid lane for onchain data agents: an agent asks about data from a Uniswap pool, gets &lt;code&gt;402 Payment Required&lt;/code&gt;, pays, and gets the answer. One rail settles on Hedera testnet through a public x402 facilitator, Blocky402.&lt;/p&gt;

&lt;p&gt;This article follows one real request: transaction &lt;code&gt;0.0.7162784@1788791855.758948636&lt;/code&gt;, settled 2026-09-07, moving 0.84367844 HBAR ($0.07) from buyer to seller, with zero buyer gas and a receipt on HCS topic &lt;code&gt;0.0.10408013&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A paid HTTP request is three headers and two facilitator calls.&lt;/strong&gt; &lt;code&gt;PAYMENT-REQUIRED&lt;/code&gt; goes out with the 402, &lt;code&gt;PAYMENT-SIGNATURE&lt;/code&gt; comes back, and &lt;code&gt;PAYMENT-RESPONSE&lt;/code&gt; goes out with the 200. In between, the server calls the facilitator's &lt;code&gt;/verify&lt;/code&gt; before doing the work and &lt;code&gt;/settle&lt;/code&gt; after.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;On Hedera, the "signature" is a transaction.&lt;/strong&gt; On EVM chains, x402 uses an &lt;a href="https://eips.ethereum.org/EIPS/eip-3009" rel="noopener noreferrer"&gt;EIP-3009&lt;/a&gt; authorization. Hedera has nothing like it, so the buyer builds a transfer, names the facilitator's account as fee payer, and signs only its own part. What it sends is a transaction it cannot submit. The facilitator adds the missing signature and submits it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replay protection has to live on the seller too&lt;/strong&gt;, or someone could buy one answer and walk away with two.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The receipt goes on a public HCS topic, not in our database&lt;/strong&gt;, so anyone can check settled volume without asking us.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You can find the project repo on my GitHub&lt;/strong&gt;: &lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Turnstile&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A status code nobody used
&lt;/h2&gt;

&lt;p&gt;HTTP has had a status code for payments since the 1990s, but almost nobody has used it. MDN still describes &lt;code&gt;402 Payment Required&lt;/code&gt; as nonstandard, reserved for digital cash or micropayment systems, and notes that "no standard use convention exists". So for decades the answer to "how does a program pay for an API call" has been: sign up to a platform, get an API key, add a card, and trust that the provider's billing dashboard agrees with your logs.&lt;/p&gt;

&lt;p&gt;That model breaks for AI agents. An agent that needs a data seller at runtime can't fill in a signup form, and the seller doesn't want a customer relationship for a seven-cent query. What both sides want is simple. The server names a price, the client pays in the next request, the server hands over the answer.&lt;/p&gt;

&lt;p&gt;x402, an open standard now looked after by the x402 Foundation, turns that into a protocol. Turnstile needed it at its center, because the whole product is a seller agent selling an answer to a buyer agent. I built it over ETHOnline 2026.&lt;/p&gt;

&lt;h2&gt;
  
  
  x402 in one round trip
&lt;/h2&gt;

&lt;p&gt;The x402 v2 HTTP transport spec is short. Three headers, each carrying base64-encoded JSON:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Header&lt;/th&gt;
&lt;th&gt;Direction&lt;/th&gt;
&lt;th&gt;Carries&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;PAYMENT-REQUIRED&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;server to client, with the 402&lt;/td&gt;
&lt;td&gt;a &lt;code&gt;PaymentRequired&lt;/code&gt; object: the resource, and an &lt;code&gt;accepts[]&lt;/code&gt; array of ways to pay&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;PAYMENT-SIGNATURE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;client to server, on the retry&lt;/td&gt;
&lt;td&gt;a &lt;code&gt;PaymentPayload&lt;/code&gt;: the &lt;code&gt;accepts[]&lt;/code&gt; entry the client picked, plus a scheme-specific &lt;code&gt;payload&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;PAYMENT-RESPONSE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;server to client, with the 200&lt;/td&gt;
&lt;td&gt;the settlement result: success, transaction id, network, payer&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each entry in &lt;code&gt;accepts[]&lt;/code&gt; names a &lt;strong&gt;scheme&lt;/strong&gt; (Turnstile only uses &lt;code&gt;exact&lt;/code&gt;; the spec also defines &lt;code&gt;upto&lt;/code&gt;, &lt;code&gt;batch-settlement&lt;/code&gt; and &lt;code&gt;auth-capture&lt;/code&gt;), a &lt;strong&gt;network&lt;/strong&gt; as a CAIP-2 id, an &lt;strong&gt;asset&lt;/strong&gt;, an &lt;strong&gt;amount&lt;/strong&gt; in the asset's smallest unit, a &lt;strong&gt;payTo&lt;/strong&gt; address, and an &lt;code&gt;extra&lt;/code&gt; bag for anything specific to that chain.&lt;/p&gt;

&lt;p&gt;The third party is the &lt;strong&gt;facilitator&lt;/strong&gt;, a service with two REST endpoints: &lt;code&gt;POST /verify&lt;/code&gt;, which checks a payment without moving anything, and &lt;code&gt;POST /settle&lt;/code&gt;, which puts it on chain. The spec says &lt;code&gt;/verify&lt;/code&gt; "MUST NOT commit payment state or write onchain state". The default ordering, called &lt;code&gt;authorization&lt;/code&gt;, is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Verify&lt;/strong&gt;: the facilitator checks that the signed payment is valid. Nothing moves.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource&lt;/strong&gt;: the server runs the handler and computes the answer. In the snippet below, that's &lt;code&gt;const body = await handler(req)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Settle&lt;/strong&gt;: the facilitator puts the payment on chain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Respond&lt;/strong&gt;: the server sends the answer back with &lt;code&gt;PAYMENT-RESPONSE&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In Turnstile's &lt;code&gt;seller/service/x402.ts&lt;/code&gt;, it looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// verify -&amp;gt; do the work -&amp;gt; settle.&lt;/span&gt;
&lt;span class="n"&gt;verified&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;rail&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;verify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;offered&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;accepts&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;verified&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;valid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;sendChallenge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;challenge&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;          &lt;span class="c1"&gt;// the work, before any value moves&lt;/span&gt;

&lt;span class="n"&gt;receipt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;rail&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;settle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;receipt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;success&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// The work is done but unpaid. Withholding it is the only option that&lt;/span&gt;
  &lt;span class="c1"&gt;// neither gives the answer away nor charges for one not delivered.&lt;/span&gt;
  &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;402&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`settlement failed on ${rail.id}: ...`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;accepts&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'PAYMENT-RESPONSE'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;encodePaymentResponseHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;receiptToSettleResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;receipt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Trimmed from &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/seller/service/x402.ts" rel="noopener noreferrer"&gt;&lt;code&gt;seller/service/x402.ts&lt;/code&gt;&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;One design choice matters for the rest of this article. Turnstile's seller offers several chains in the same 402 and lets the buyer pick, so the code that gates the route can't depend on any of them. Nothing under &lt;code&gt;seller/service/&lt;/code&gt; knows what a chain is.&lt;/p&gt;

&lt;p&gt;Everything specific to Hedera travels in two separate pieces, &lt;code&gt;extra&lt;/code&gt; on the way out and &lt;code&gt;payload&lt;/code&gt; on the way back, and the service copies both without reading them. That way, adding a chain never means editing the code that takes money: adding Base later needed no changes on the payment path. How that seam works is in &lt;a href="https://ignaciopastorsanchez.com/blog/chain-agnostic-x402-seller-payment-rails" rel="noopener noreferrer"&gt;One payment interface, four chains&lt;/a&gt;. This article is about what goes inside on Hedera.&lt;/p&gt;

&lt;h2&gt;
  
  
  x402 on EVM
&lt;/h2&gt;

&lt;p&gt;On regular EVM chains, x402's &lt;code&gt;exact&lt;/code&gt; scheme defaults to EIP-3009, &lt;code&gt;transferWithAuthorization&lt;/code&gt;. The payer signs an &lt;a href="https://eips.ethereum.org/EIPS/eip-712" rel="noopener noreferrer"&gt;EIP-712&lt;/a&gt; message saying "move X USDC from me to Y, valid between these times, with this random nonce". Anyone holding that signature can submit it, so the facilitator submits it and pays the gas. The payer never sends a transaction.&lt;/p&gt;

&lt;p&gt;Turnstile's other rail, on Arc through Circle Gateway, does exactly that. I wrote it up in &lt;a href="https://ignaciopastorsanchez.com/blog/gasless-nanopayments-eip3009-circle-gateway-arc" rel="noopener noreferrer"&gt;Gasless nanopayments on Arc, and the nonce that stays at 0&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This works because the token contract has a function that accepts someone else's signature. Hedera's native HBAR and HTS tokens have no such function. So what does "sign, but let someone else pay" look like when the thing you sign has to be a real transaction?&lt;/p&gt;

&lt;h2&gt;
  
  
  The Hedera version: a transaction you cannot send
&lt;/h2&gt;

&lt;p&gt;First, Hedera isn't an EVM chain underneath. It's its own ledger with an EVM compatibility layer on top:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The native layer runs hashgraph consensus, names accounts &lt;code&gt;0.0.xxxx&lt;/code&gt;, and treats HBAR and HTS tokens as part of the ledger rather than as contracts: you move them with a native &lt;code&gt;TransferTransaction&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The EVM layer, the Hedera Smart Contract Service, runs Solidity on Besu's EVM behind a JSON-RPC relay, with chain id 295 on mainnet and 296 on testnet, and lets contracts call HTS tokens through an ERC-20-style interface.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;x402's Hedera binding uses the native layer, under its own CAIP-2 namespace, &lt;code&gt;hedera:&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Back to the question. The answer hangs on one native detail. Hedera's docs say a transaction id is "composed of the account ID of the account paying for the transaction and the transaction's valid start time", written &lt;code&gt;accountID@validStartTime&lt;/code&gt;, and that "the account paying for the transaction must always sign". &lt;strong&gt;On Hedera, the fee payer is part of the transaction's identity.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The x402 &lt;code&gt;exact&lt;/code&gt; scheme spec for Hedera builds on that. In order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The 402's &lt;code&gt;extra&lt;/code&gt; must include a &lt;code&gt;feePayer&lt;/code&gt;, "the Hedera account ID (&lt;code&gt;0.0.xxxx&lt;/code&gt;) of the identity that will pay the network fees". This is usually the &lt;strong&gt;facilitator&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The client builds a &lt;code&gt;TransferTransaction&lt;/code&gt; from itself to &lt;code&gt;payTo&lt;/code&gt; for &lt;code&gt;amount&lt;/code&gt;, and "sets the &lt;code&gt;transactionId.accountId&lt;/code&gt; to &lt;code&gt;PaymentRequirements.extra.feePayer&lt;/code&gt;".&lt;/li&gt;
&lt;li&gt;The client signs it. That gives "a &lt;strong&gt;partially signed&lt;/strong&gt; transaction (the fee payer's signature is still missing)".&lt;/li&gt;
&lt;li&gt;The client base64-encodes it and sends it as &lt;code&gt;payload.transaction&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The resource server passes it to &lt;code&gt;/verify&lt;/code&gt;, then &lt;code&gt;/settle&lt;/code&gt;. On settle, the facilitator "adds its signature as the &lt;code&gt;feePayer&lt;/code&gt; and submits the now fully signed transaction".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The partially signed transaction can be tricky to understand at first. It has the full shape of a valid transaction, minus one required signature.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The buyer can't broadcast it, because the fee payer hasn't signed.&lt;/li&gt;
&lt;li&gt;The seller can't change it, because editing the body would break the buyer's signature.&lt;/li&gt;
&lt;li&gt;The facilitator can't redirect the money either: the spec requires it to reject anything except a plain transfer that sends exactly &lt;code&gt;amount&lt;/code&gt; to &lt;code&gt;payTo&lt;/code&gt;, and forbids the fee payer from appearing as a net sender of funds. The facilitator can pay the fee or refuse. Nothing else.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's the 402 Turnstile sent for the request in this article:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"scheme"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"exact"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"network"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"hedera:testnet"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"asset"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"84367844"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"payTo"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0.0.10403961"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"maxTimeoutSeconds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"extra"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"feePayer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0.0.7162784"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"facilitator"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://api.testnet.blocky402.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"settlementModel"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"facilitator-cosigned-transaction"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"decimals"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"priceUsd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.07&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"usdPerUnit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.08297&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"rateSource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"hedera mirror node /api/v1/network/exchangerate (248910 cents per 30000 HBAR)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"turnstileSettlement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"live"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;The &lt;code&gt;accepts[]&lt;/code&gt; entry, trimmed, from &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/docs/payment-flow.md" rel="noopener noreferrer"&gt;&lt;code&gt;docs/payment-flow.md&lt;/code&gt;&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Four things in it are easy to get wrong.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;network&lt;/code&gt; is &lt;code&gt;hedera:testnet&lt;/code&gt;, not &lt;code&gt;eip155:296&lt;/code&gt;.&lt;/strong&gt; Blocky402 lists Hedera under its own CAIP-2 namespace.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;asset&lt;/code&gt; is &lt;code&gt;0.0.0&lt;/code&gt;, native HBAR&lt;/strong&gt;, as the spec reserves. Testnet USDC exists, but an HTS transfer needs both accounts associated with the token first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;amount&lt;/code&gt; is in tinybars, with 8 decimals.&lt;/strong&gt; One HBAR is 10⁸ tinybars. Using USDC's 6 decimals by habit would underpay by a factor of 100.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The price is set in dollars and converted at Hedera's own network exchange rate&lt;/strong&gt;, read from the public mirror node: 248,910 cents per 30,000 HBAR is $0.08297 per HBAR, and $0.07 at that rate is 84,367,844 tinybars. In Turnstile the buyer reads the rate for itself and ignores the seller's &lt;code&gt;usdPerUnit&lt;/code&gt;. Otherwise a seller could name any price and pick a rate that makes it look like seven cents.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the buyer side, the x402 Foundation's &lt;code&gt;@x402/hedera&lt;/code&gt; package builds the transaction, because the facilitator rejects anything that doesn't match the shape it expects:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;PrivateKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;createClientHederaSigner&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@x402/hedera'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;inner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createClientHederaSigner&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;accountId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;PrivateKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromStringECDSA&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rawKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;network&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// ...inside the RailSigner:&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;requirement&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;inner&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createPartiallySignedTransferTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;requirement&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Trimmed from &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/buyer/watchdog/hedera-signer.ts" rel="noopener noreferrer"&gt;&lt;code&gt;buyer/watchdog/hedera-signer.ts&lt;/code&gt;&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The seller side needs even less. &lt;code&gt;@x402/hedera&lt;/code&gt; also ships a facilitator scheme, the code that adds the fee payer's signature and submits the transfer. It can only run where the fee payer's private key lives, and that key belongs to Blocky402. Our server never holds it; it only talks to Blocky402 over HTTP, so &lt;code&gt;rails/hedera-x402/facilitator.ts&lt;/code&gt; is a plain &lt;code&gt;fetch&lt;/code&gt; client making three calls:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;GET /supported&lt;/code&gt;, to learn which account pays the fees, so the seller can put it in the challenge's &lt;code&gt;extra.feePayer&lt;/code&gt;. The answer is cached, since it changes only if Blocky402 rotates that account.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;POST /verify&lt;/code&gt;, before the work.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;POST /settle&lt;/code&gt;, after it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both POSTs send the same body: &lt;code&gt;{ x402Version, paymentPayload, paymentRequirements }&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blocky402
&lt;/h3&gt;

&lt;p&gt;Blocky402 is an open-source (MIT) x402 facilitator from BlockyDevs. The hosted version covers Polygon Amoy, Solana Devnet and Hedera Testnet, plus Hedera mainnet. On testnet it needed no signup and no API key. An unauthenticated &lt;code&gt;GET /supported&lt;/code&gt; returned the Hedera entry along with its fee payer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"x402Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"scheme"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"exact"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"network"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"hedera:testnet"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"extra"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"feePayer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"0.0.7162784"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rail doesn't hardcode that account. &lt;code&gt;challenge()&lt;/code&gt; reads &lt;code&gt;/supported&lt;/code&gt; (cached for five minutes), so if Blocky402 rotates its fee payer, the seller answers 503 instead of issuing unpayable quotes. Hedera's own &lt;code&gt;x402-inference-pay-per-request-poc&lt;/code&gt; also routes its mainnet payments through &lt;code&gt;api.blocky402.com&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What landed on chain
&lt;/h2&gt;

&lt;p&gt;Anyone can read the settled transaction from Hedera's public testnet mirror node, no key needed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"CRYPTOTRANSFER"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"result"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"SUCCESS"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"transaction_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0.0.7162784-1788791855-758948636"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"charged_tx_fee"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;241050&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"transfers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"account"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0.0.802"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;      &lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;241050&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"account"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0.0.7162784"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;-241050&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"account"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0.0.10403961"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;84367844&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"account"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0.0.10408012"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;-84367844&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;From &lt;code&gt;GET https://testnet.mirrornode.hedera.com/api/v1/transactions/0.0.7162784-1788791855-758948636&lt;/code&gt;, trimmed.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let's check the transaction id. It starts with &lt;code&gt;0.0.7162784&lt;/code&gt;, Blocky402's account, not the buyer's. That account paid the 241,050-tinybar fee. The buyer, &lt;code&gt;0.0.10408012&lt;/code&gt;, went down by exactly the price. The seller, &lt;code&gt;0.0.10403961&lt;/code&gt;, went up by exactly the price.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbi0l7o1o6631cvks3efd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbi0l7o1o6631cvks3efd.png" alt="The same transaction on HashScan: Blocky402's account 0.0.7162784 pays the fee, and $0.07 moves from the buyer 0.0.10408012 to the seller 0.0.10403961" width="800" height="472"&gt;&lt;/a&gt;That transfer list is the whole gasless claim.&lt;/p&gt;

&lt;h2&gt;
  
  
  The replay guard
&lt;/h2&gt;

&lt;p&gt;The scheme spec says the transaction must "not have been previously submitted/observed", and facilitators "SHOULD perform idempotency / replay checks where possible". The network enforces this at its own level too: a frozen transaction has a unique id, and Hedera rejects a duplicate.&lt;/p&gt;

&lt;p&gt;For a seller, that protection comes too late. Our ordering is verify, work, settle. If someone sends the same &lt;code&gt;PAYMENT-SIGNATURE&lt;/code&gt; twice, both copies can pass &lt;code&gt;/verify&lt;/code&gt; before either settles. The analyst runs twice and hands over two answers, and only then does the second settlement fail.&lt;/p&gt;

&lt;p&gt;Hedera stops the double charge, but nothing stops the double delivery. So the seller keeps track of what it has already been paid with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// The replay guard. A frozen Hedera transaction has a unique transaction&lt;/span&gt;
&lt;span class="c1"&gt;// id, so the network itself rejects a second submission with&lt;/span&gt;
&lt;span class="c1"&gt;// DUPLICATE_TRANSACTION, but only after we have already done the work and&lt;/span&gt;
&lt;span class="c1"&gt;// handed over the answer. Refusing here is what makes one payment buy&lt;/span&gt;
&lt;span class="c1"&gt;// exactly one answer.&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isSpent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;signedTransaction&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;valid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'already_settled'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;payer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;detail&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'this transaction has already been settled by this seller'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;From &lt;code&gt;verify()&lt;/code&gt; in &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/rails/hedera-x402/index.ts" rel="noopener noreferrer"&gt;&lt;code&gt;rails/hedera-x402/index.ts&lt;/code&gt;&lt;/a&gt;. The key is the base64 of the bytes the payer signed.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The test script builds one payment by hand and sends the same header twice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;first send  -&amp;gt; HTTP 200  0.0.7162784@1788791871.396045089
second send -&amp;gt; HTTP 402
               payment rejected by hedera-x402: already_settled -
               this transaction has already been settled by this seller
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The normal &lt;code&gt;@x402/fetch&lt;/code&gt; client can't demonstrate this failure, because it creates a fresh transaction for every call, which is the correct thing for a client to do. That's why the guard belongs on the seller.&lt;/p&gt;

&lt;p&gt;Our implementation has two limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The spent set is in memory (&lt;code&gt;SettlementBook&lt;/code&gt; "survives one process"), so it doesn't survive a restart or span several instances. That's fine for a one-host hackathon, not for production.&lt;/li&gt;
&lt;li&gt;The resource binding is weaker than it looks. &lt;code&gt;verify()&lt;/code&gt; compares &lt;code&gt;extra.resource&lt;/code&gt;, but a Hedera transaction commits to &lt;code&gt;payTo&lt;/code&gt;, &lt;code&gt;amount&lt;/code&gt;, &lt;code&gt;asset&lt;/code&gt; and &lt;code&gt;feePayer&lt;/code&gt;, not to a URL, so a payer can edit it. What stops a $0.07 payment buying the $0.35 tier is the amount check against a fresh quote, plus the replay guard.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A receipt anyone can read
&lt;/h2&gt;

&lt;p&gt;After every settlement, the rail writes one message to a Hedera Consensus Service topic. Hedera describes HCS as a way to "create a verifiable timestamp and order of events for any application": an append-only log the network orders and timestamps, readable by anyone through a mirror node.&lt;/p&gt;

&lt;p&gt;The reason is discovery. Turnstile ranks sellers by settled volume, and a seller keeping receipts in its own SQLite can write whatever it likes. So the receipt goes to the topic, and the database becomes a cache of something anyone can check.&lt;/p&gt;

&lt;p&gt;Here's the message for this payment, decoded from the mirror node while writing this. It's sequence number 5 on topic &lt;code&gt;0.0.10408013&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"v"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"kind"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"turnstile.settlement"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"railId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"hedera-x402"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"network"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"hedera:testnet"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="nl"&gt;"transaction"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"0.0.7162784@1788791855.758948636"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"payer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"0.0.10408012"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="nl"&gt;"payTo"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"0.0.10403961"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"84367844"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"asset"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"0.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"priceUsd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mf"&gt;0.07&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="nl"&gt;"resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"http://127.0.0.1:33871/analyze/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="nl"&gt;"settledAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1788791866251&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reading it back needs no key and no SDK, just the route anyone could use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;limit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;HcsReceiptMessage&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sb"&gt;`${this.mirrorNodeUrl}/api/v1/topics/${this.topicId}/messages?limit=${limit}&amp;amp;order=asc`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;doFetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;AbortSignal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20_000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;HcsReceiptMessage&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;entry&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Mirror node returns the message base64-encoded.&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;parsed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'base64'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'utf8'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="c1"&gt;// Someone else's message on our topic is possible if the topic has no&lt;/span&gt;
      &lt;span class="c1"&gt;// submit key. Filtering on the marker is cheaper than trusting it.&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parsed&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'turnstile.settlement'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parsed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* not ours, not JSON: skip */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Trimmed from &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/rails/hedera-x402/hcs.ts" rel="noopener noreferrer"&gt;&lt;code&gt;rails/hedera-x402/hcs.ts&lt;/code&gt;&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The topic has no submit key.&lt;/strong&gt; Anyone can post to it. That's why the reader filters on &lt;code&gt;kind&lt;/code&gt; and skips anything it can't parse.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The message records what was bought, never what was sold.&lt;/strong&gt; The topic is public, so writing the analyst's verdict into it would give away the thing the buyer paid for.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A failed HCS write doesn't fail the payment.&lt;/strong&gt; The transfer already settled. Refusing to deliver the answer because of a bookkeeping failure would punish the buyer for an error on our side. The result goes in &lt;code&gt;Receipt.extra.hcs&lt;/code&gt;, so a missing receipt shows up instead of disappearing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On trust: a message on an open topic proves someone &lt;em&gt;said&lt;/em&gt; a payment happened. The receipt is worth something because its &lt;code&gt;transaction&lt;/code&gt; field can be checked against the ledger on the mirror node. The ingestion job reads the topic, not our own &lt;code&gt;settle()&lt;/code&gt; results.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gotcha: two transaction id formats
&lt;/h2&gt;

&lt;p&gt;Hedera's SDK and its docs write a transaction id as &lt;code&gt;0.0.7162784@1788791855.758948636&lt;/code&gt;. The mirror node REST API wants &lt;code&gt;0.0.7162784-1788791855-758948636&lt;/code&gt; in the URL path. Its own OpenAPI spec gives the example &lt;code&gt;0.0.10-1234567890-000000000&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;toMirrorNodeTransactionId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transactionId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;transactionId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'@'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'-'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;\&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'-$1'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;From &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/rails/hedera-x402/config.ts" rel="noopener noreferrer"&gt;&lt;code&gt;rails/hedera-x402/config.ts&lt;/code&gt;&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;@&lt;/code&gt; form, raw or URL-encoded, returns &lt;strong&gt;400&lt;/strong&gt; with the message &lt;code&gt;Invalid Transaction id. Please use "shard.realm.num-sss-nnn" format&lt;/code&gt;. A well-formed id that doesn't exist returns 404 &lt;code&gt;Not found&lt;/code&gt;. So the server tells the two cases apart. Where they collapsed into one was in our own code: &lt;code&gt;receipt()&lt;/code&gt; does &lt;code&gt;if (!res.ok) return null&lt;/code&gt;, so a bad format and a missing transaction both come back as &lt;code&gt;null&lt;/code&gt;. The fix is the same either way: convert the id before building the URL.&lt;/p&gt;

&lt;p&gt;HashScan links use the &lt;code&gt;@&lt;/code&gt; form, but HashScan answers 404 to curl on every path, so the repo relies on the mirror node link.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the protocol leaves to the seller
&lt;/h2&gt;

&lt;p&gt;Followed down to the transfer list, an agent paying for an API call is four lines on the mirror node. The facilitator pays 241,050 tinybars in fees, the buyer loses 84,367,844 tinybars, and the seller gains them. The buyer's key signed one transfer to one account and had no gas for anything else (&lt;a href="https://ignaciopastorsanchez.com/blog/privy-spending-mandates-key-quorums" rel="noopener noreferrer"&gt;how that key gets its limit&lt;/a&gt;). x402 and Blocky402 got the money there.&lt;/p&gt;

&lt;p&gt;They left two jobs to the seller:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stopping replays&lt;/strong&gt;: the same payment header sent twice bought two answers until our seller kept a list of spent transactions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Public receipts&lt;/strong&gt;: a seller's own database could claim any volume it wanted until the receipts went to a topic anyone can read.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the start of this article, paying for an API meant an account, a key, a card, and trusting the provider's billing dashboard. Turnstile replaces that with x402 plus those two checks, and that's what a marketplace of data agents needs: an agent the seller has never met pays seven cents, gets exactly one answer, and leaves a receipt anyone can check against the ledger.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.x402.org" rel="noopener noreferrer"&gt;x402.org&lt;/a&gt;: x402 is an open standard for internet-native payments built on HTTP 402, stewarded by the x402 Foundation.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/x402-foundation/x402/blob/main/specs/transports-v2/http.md" rel="noopener noreferrer"&gt;x402 v2 HTTP transport spec&lt;/a&gt;: the &lt;code&gt;PAYMENT-REQUIRED&lt;/code&gt;, &lt;code&gt;PAYMENT-SIGNATURE&lt;/code&gt; and &lt;code&gt;PAYMENT-RESPONSE&lt;/code&gt; headers as base64-encoded JSON.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/x402-foundation/x402/blob/main/specs/x402-specification-v2.md" rel="noopener noreferrer"&gt;x402 v2 core specification&lt;/a&gt;: facilitator &lt;code&gt;/verify&lt;/code&gt; (read-only) and &lt;code&gt;/settle&lt;/code&gt;, and the default &lt;code&gt;authorization&lt;/code&gt; flow (verify, resource, settle).&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_hedera.md" rel="noopener noreferrer"&gt;x402 &lt;code&gt;exact&lt;/code&gt; scheme on Hedera&lt;/a&gt;: &lt;code&gt;extra.feePayer&lt;/code&gt;, the partially signed &lt;code&gt;TransferTransaction&lt;/code&gt;, &lt;code&gt;0.0.0&lt;/code&gt; for HBAR, tinybar amounts, facilitator verification rules and replay checks.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_evm.md" rel="noopener noreferrer"&gt;x402 &lt;code&gt;exact&lt;/code&gt; scheme on EVM&lt;/a&gt;: EIP-3009 is the default asset transfer method, Permit2 the fallback.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/coinbase/x402" rel="noopener noreferrer"&gt;coinbase/x402 on GitHub&lt;/a&gt;: the original home of the reference implementation (the same project is published under &lt;code&gt;x402-foundation/x402&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://registry.npmjs.org/@x402/hedera/2.25.0" rel="noopener noreferrer"&gt;&lt;code&gt;@x402/hedera&lt;/code&gt; 2.25.0 registry manifest&lt;/a&gt;: exact pins on &lt;code&gt;@hiero-ledger/sdk&lt;/code&gt; 2.85.0 and &lt;code&gt;@hiero-ledger/proto&lt;/code&gt; 2.31.0, and the lockstep note.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/402" rel="noopener noreferrer"&gt;MDN: 402 Payment Required&lt;/a&gt;: nonstandard, reserved for payment systems, no standard use convention.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://eips.ethereum.org/EIPS/eip-712" rel="noopener noreferrer"&gt;EIP-712: Typed structured data hashing and signing&lt;/a&gt;: the message format the payer signs for an EIP-3009 authorization.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://eips.ethereum.org/EIPS/eip-3009" rel="noopener noreferrer"&gt;ERC-3009: Transfer With Authorization&lt;/a&gt;: signed authorizations that a third party submits, with validity windows and random nonces (status: Draft).&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.hedera.com/learn/core-concepts/transactions/properties.md" rel="noopener noreferrer"&gt;Hedera docs: Transaction Properties&lt;/a&gt;: the transaction id is the paying account plus valid start time, and the paying account must always sign.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.hedera.com/support/glossary.md" rel="noopener noreferrer"&gt;Hedera docs: Glossary&lt;/a&gt;: definitions of HCS (verifiable timestamps and ordering), HTS, and mirror nodes.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://testnet.mirrornode.hedera.com/api/v1/docs/openapi.yml" rel="noopener noreferrer"&gt;Hedera testnet mirror node OpenAPI&lt;/a&gt;: transaction id path parameter in the &lt;code&gt;0.0.10-1234567890-000000000&lt;/code&gt; format.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://testnet.mirrornode.hedera.com/api/v1/transactions/0.0.7162784-1788791855-758948636" rel="noopener noreferrer"&gt;Mirror node record for the transaction&lt;/a&gt;: &lt;code&gt;SUCCESS&lt;/code&gt;, fee charged to &lt;code&gt;0.0.7162784&lt;/code&gt;, exact buyer debit and seller credit.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://testnet.mirrornode.hedera.com/api/v1/topics/0.0.10408013/messages?limit=100&amp;amp;order=asc" rel="noopener noreferrer"&gt;Mirror node messages for topic 0.0.10408013&lt;/a&gt;: the settlement receipt at sequence number 5, readable with no key.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://blocky402.com" rel="noopener noreferrer"&gt;Blocky402&lt;/a&gt;: open-source (MIT) x402 facilitator by BlockyDevs, and the networks it covers.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://api.testnet.blocky402.com/supported" rel="noopener noreferrer"&gt;Blocky402 testnet &lt;code&gt;/supported&lt;/code&gt;&lt;/a&gt;: &lt;code&gt;exact&lt;/code&gt; on &lt;code&gt;hedera:testnet&lt;/code&gt; with fee payer &lt;code&gt;0.0.7162784&lt;/code&gt;, no authentication.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/hedera-dev/x402-inference-pay-per-request-poc" rel="noopener noreferrer"&gt;hedera-dev/x402-inference-pay-per-request-poc&lt;/a&gt;: Hedera's own x402 proof of concept, using &lt;code&gt;api.blocky402.com&lt;/code&gt; as its mainnet facilitator.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/IpastorSan/turnstile" rel="noopener noreferrer"&gt;Turnstile repository&lt;/a&gt;: all code excerpts; &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/docs/payment-flow.md" rel="noopener noreferrer"&gt;&lt;code&gt;docs/payment-flow.md&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/docs/EVIDENCE.md" rel="noopener noreferrer"&gt;&lt;code&gt;docs/EVIDENCE.md&lt;/code&gt;&lt;/a&gt; for the run, &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/CORRECTIONS.md" rel="noopener noreferrer"&gt;&lt;code&gt;CORRECTIONS.md&lt;/code&gt;&lt;/a&gt; for what was wrong, &lt;a href="https://github.com/IpastorSan/turnstile/blob/main/AI-USE.md" rel="noopener noreferrer"&gt;&lt;code&gt;AI-USE.md&lt;/code&gt;&lt;/a&gt; for how it was built.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Next in the series:&lt;/strong&gt; &lt;a href="https://ignaciopastorsanchez.com/blog/gasless-nanopayments-eip3009-circle-gateway-arc" rel="noopener noreferrer"&gt;Gasless nanopayments on Arc, and the nonce that stays at 0&lt;/a&gt;, part 2 of 9.&lt;/p&gt;

</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>ai</category>
      <category>agents</category>
    </item>
    <item>
      <title>Bankr's Migration to Doppler Protocol: A Technical Deep Dive</title>
      <dc:creator>Ignacio Pastor Sánchez</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:35:34 +0000</pubDate>
      <link>https://dev.to/ignacio_pastor/bankrs-migration-to-doppler-protocol-a-technical-deep-dive-5a8h</link>
      <guid>https://dev.to/ignacio_pastor/bankrs-migration-to-doppler-protocol-a-technical-deep-dive-5a8h</guid>
      <description>&lt;h2&gt;
  
  
  What Happened
&lt;/h2&gt;

&lt;p&gt;Bankr has migrated their token launcher from Clanker to &lt;strong&gt;Doppler Protocol&lt;/strong&gt;, the same professional-grade infrastructure used by Zora, Paragraph, and Noice. This isn't a fork or a copy: Bankr is using the &lt;strong&gt;canonical Doppler contracts&lt;/strong&gt; on Base, deployed and maintained by Whetstone Research.&lt;/p&gt;

&lt;p&gt;This article breaks down the technical architecture, explains the liquidity mechanics, and clarifies what this means if you're trading these tokens.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Bankr's initial Feb 10 deployment used &lt;code&gt;ScheduledMulticurveInitializer&lt;/code&gt;. Within three days, they switched to &lt;code&gt;DecayMulticurveInitializer&lt;/code&gt; with a significantly different curve structure. The article documents both setups. Skip to Current Setup if you only care about how it works now.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The Core Infrastructure
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Airlock Pattern
&lt;/h3&gt;

&lt;p&gt;Doppler uses a modular "Airlock" architecture where a central orchestrator contract delegates to specialized components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Airlock (0x660eAaEdEBc968f8f3694354FA8EC0b4c5Ba8D12)
    ├── TokenFactory80 → Deploys DERC20 tokens
    │
    ├── Pool Initializer (one of):
    │     ├─ ScheduledMulticurveInitializer (0xA36715d..., Feb 10)
    │     │    └── Hook: binary start-time gate
    │     │
    │     └─ DecayMulticurveInitializer (0xd59ce43..., Feb 13+) ← CURRENT
    │          └── Hook: 80% → 1.2% fee decay over 10s
    │
    ├── NoOpGovernanceFactory → Immutable, no admin controls
    ├── NoOpMigrator → Required param (always reverts)
    └── StreamableFeesLockerV2 → Locks positions, streams fees
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key takeaway:&lt;/strong&gt; Once deployed, these tokens are fully immutable. No admin can change parameters, pause trading, or rug the liquidity.&lt;/p&gt;




&lt;h2&gt;
  
  
  Original Liquidity Design: Scheduled Multicurve (Feb 10)
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Historical:&lt;/strong&gt; This section describes Bankr's initial setup which was replaced on Feb 13. See Current Setup for the active configuration.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Bankr's initial deployment used Doppler's &lt;strong&gt;Uniswap V4 Scheduled Multicurve&lt;/strong&gt; with four overlapping curve definitions subdivided into ~21 segments.&lt;/p&gt;

&lt;h3&gt;
  
  
  What This Means Technically
&lt;/h3&gt;

&lt;p&gt;Instead of a single liquidity position or full-range V3 LP, Bankr tokens launch with:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;colgroup&gt;
&lt;col&gt;
&lt;col&gt;
&lt;/colgroup&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Component&lt;/p&gt;&lt;/th&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Specification&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;DEX Version&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Uniswap V4&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Fee Tier&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;1.2% (12,000 pips)&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Tick Spacing&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;200&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Curve Structure&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;4 curves → ~21 segments&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Liquidity Lock&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;StreamableFeesLockerV2 (time-locked)&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Trading Gate&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;code&gt;startingTime&lt;/code&gt; timestamp on hook&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  The Four Curves (Example: BlueWhale deployment)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;colgroup&gt;
&lt;col&gt;
&lt;col&gt;
&lt;col&gt;
&lt;col&gt;
&lt;col&gt;
&lt;/colgroup&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Curve&lt;/p&gt;&lt;/th&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Tick Range&lt;/p&gt;&lt;/th&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Segments&lt;/p&gt;&lt;/th&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;ETH/Segment&lt;/p&gt;&lt;/th&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Purpose&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;1&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;[-230,200 → -219,200]&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;10&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;0.2 ETH&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Core range — widest coverage&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;2&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;[-222,000 → -215,200]&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;5&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;0.25 ETH&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Mid concentration&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;3&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;[-216,200 → -210,000]&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;5&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;0.35 ETH&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Tightest concentration&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;4&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;[-210,800 → +887,200]&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;1&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;0.2 ETH&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Safety net (thin)&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Total deployed:&lt;/strong&gt; ~4.55 ETH across 21 positions&lt;/p&gt;

&lt;h3&gt;
  
  
  Market Cap Depth Map (WETH @ ~$2,700)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;colgroup&gt;
&lt;col&gt;
&lt;col&gt;
&lt;col&gt;
&lt;/colgroup&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Zone&lt;/p&gt;&lt;/th&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Mcap Range&lt;/p&gt;&lt;/th&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Depth Characteristic&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;$27K → $61K&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Curve 1 only&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Thin, easy to push through&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;$61K → $82K&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Curves 1+2 overlap&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;~2x depth&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;$82K → $108K&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Curve 2 only&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Moderate&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;$108K → $122K&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Curves 2+3 overlap&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;~2x depth&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;$122K → $189K&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Curve 3 only&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Moderate&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;$189K → $205K&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Curves 3+4 overlap&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;~2x depth&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;$205K+&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Curve 4 only&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Extremely thin — cliff edge&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Critical Trading Implications
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Designed for Volatility, Not Stability
&lt;/h3&gt;

&lt;p&gt;The liquidity structure is optimized for &lt;strong&gt;fast, violent price action&lt;/strong&gt; in a narrow mcap band:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Entire concentrated range:&lt;/strong&gt; $27K → $205K (7.5x price journey)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Beyond $205K:&lt;/strong&gt; Near-zero liquidity, price can moon or crater on minimal volume&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;All segments activate at once:&lt;/strong&gt; The "scheduled" hook is a binary gate (blocked → fully live), not gradual activation&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Bottom line:&lt;/strong&gt; These tokens are engineered for micro-cap speculation, not gradual price discovery.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  2. No External Liquidity
&lt;/h3&gt;

&lt;p&gt;The Doppler hook &lt;strong&gt;blocks all third-party liquidity additions&lt;/strong&gt;. What you see at launch is what you get:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;No retail LPs can add depth to stabilize price&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No whale can come in and provide "support"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The curve structure is immutable, no adjustments possible&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Locked but Not Burned
&lt;/h3&gt;

&lt;p&gt;Liquidity positions are locked in the &lt;code&gt;UniswapV4MulticurveInitializer&lt;/code&gt;, not burned. This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Fees stream to beneficiaries forever.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Migration is effectively disabled (&lt;code&gt;NoOpMigrator&lt;/code&gt; always reverts)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The initializer holds the liquidity position, but the fees are distributed to beneficiaries configured by the user, plus 5% for Doppler.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The "Scheduled" Hook Explained (Feb 10)
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Historical:&lt;/strong&gt; Bankr now uses &lt;code&gt;DecayMulticurveInitializerHook&lt;/code&gt; instead. See Current Setup.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Despite the name, "Scheduled" doesn't mean gradual liquidity activation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;At creation, a &lt;code&gt;startingTime&lt;/code&gt; timestamp is set&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Before that time: all swaps revert with &lt;code&gt;CannotSwapBeforeStartingTime()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After that time: &lt;strong&gt;all 21 segments are immediately tradeable&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There's no phased rollout, no time-based dampening. It's a binary switch from "no trading" to "full volatility."&lt;/p&gt;




&lt;h2&gt;
  
  
  DERC20: The Token Standard
&lt;/h2&gt;

&lt;p&gt;Doppler tokens are &lt;strong&gt;DERC20&lt;/strong&gt;, an extended ERC20 with additional built-in functionality.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;contract DERC20 is ERC20, ERC20Votes, ERC20Permit, Ownable {
    uint256 public immutable vestingStart;
    uint256 public immutable vestingDuration;
    uint256 public immutable vestedTotalAmount;
    address public pool;
    bool public isPoolUnlocked;
    uint256 public yearlyMintRate; // Max 2%
    string public tokenURI;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Built-in features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Vesting:&lt;/strong&gt; Up to 80% of supply can be time-locked&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Governance:&lt;/strong&gt; ERC20Votes for DAO functionality (though irrelevant for Bankr)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Inflation controls:&lt;/strong&gt; Max 2% yearly mint rate&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Permit2:&lt;/strong&gt; Gasless approvals.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pool locking:&lt;/strong&gt; Liquidity locked until conditions met (in our case, forever)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Current Setup (Feb 13): DecayMulticurveInitializer
&lt;/h2&gt;

&lt;p&gt;Bankr switched to a newer Doppler contract within three days of launch. The following reflects the &lt;strong&gt;current active configuration&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Current Contracts
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;colgroup&gt;
&lt;col&gt;
&lt;col&gt;
&lt;/colgroup&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Contract&lt;/p&gt;&lt;/th&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Address&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;DecayMulticurveInitializer&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;code&gt;0xd59ce43e53d69f190e15d9822fb4540dccc91178&lt;/code&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;DecayMulticurveInitializerHook&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;code&gt;0xbB7784A4d481184283Ed89619A3e3ed143e1Adc0&lt;/code&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Source:&lt;/strong&gt; &lt;a href="https://github.com/whetstoneresearch/doppler/blob/46bad16d5524661fac04a0e3cd0ea81f7648ecc7/src/initializers/DecayMulticurveInitializer.sol#L36" rel="noopener noreferrer"&gt;DecayMulticurveInitializer.sol&lt;/a&gt; / &lt;a href="https://github.com/whetstoneresearch/doppler/blob/46bad16d5524661fac04a0e3cd0ea81f7648ecc7/src/initializers/DecayMulticurveInitializerHook.sol" rel="noopener noreferrer"&gt;DecayMulticurveInitializerHook.sol&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What Changed: Decaying Fee Instead of Start-Time Gate
&lt;/h3&gt;

&lt;p&gt;The old "Scheduled" hook blocked all swaps until &lt;code&gt;startingTime&lt;/code&gt;, then opened the floodgates. The new "Decay" hook takes a different approach: &lt;strong&gt;swaps are always allowed&lt;/strong&gt;, but the fee starts extremely high and linearly decays to the terminal rate.&lt;/p&gt;

&lt;p&gt;The hook struct (from source, single storage slot):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;struct FeeSchedule {
    uint32 startingTime;
    uint24 startFee;    // Fee at start
    uint24 endFee;      // Terminal fee
    uint24 lastFee;     // Last applied (monotonically decreasing)
    uint32 durationSeconds;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Flow Caster deployment values (verified on-chain):&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;colgroup&gt;
&lt;col&gt;
&lt;col&gt;
&lt;/colgroup&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Parameter&lt;/p&gt;&lt;/th&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Value&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;startFee&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;800,000 = &lt;strong&gt;80%&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;endFee&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;12,000 = &lt;strong&gt;1.2%&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;durationSeconds&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;10 seconds&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The fee decays linearly: &lt;code&gt;currentFee = startFee - (startFee - endFee) * elapsed / durationSeconds&lt;/code&gt;. At second 0 it's 80%, at second 5 it's ~41%, at second 10 it locks at 1.2%.&lt;/p&gt;

&lt;p&gt;This is an anti-snipe mechanism. Bots that buy in the first seconds get taxed at up to 80%. Wait 10 seconds and you pay a normal 1.2%.&lt;/p&gt;

&lt;h3&gt;
  
  
  Current Curve Structure
&lt;/h3&gt;

&lt;p&gt;The Feb 10 setup used 4 overlapping curves with ~21 segments in a narrow $27K–$205K range. The current setup is much simpler:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;colgroup&gt;
&lt;col&gt;
&lt;col&gt;
&lt;col&gt;
&lt;col&gt;
&lt;/colgroup&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Curve&lt;/p&gt;&lt;/th&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Tick Range&lt;/p&gt;&lt;/th&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Share&lt;/p&gt;&lt;/th&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Mcap Range&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;0 (concentrated)&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;[-230,000 → -120,000]&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;99%&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;~$27.7K → ~$1.66B&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;1 (safety net)&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;[-120,000 → +887,200]&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;1%&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;~$1.66B → ∞&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The concentrated range now extends to &lt;strong&gt;$1.66B&lt;/strong&gt;, roughly 60x wider than the previous $205K ceiling. No overlapping curves, no stacked "speed bump" zones. One large position holds 99% of supply.&lt;/p&gt;

&lt;h3&gt;
  
  
  Revised Comparison
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;colgroup&gt;
&lt;col&gt;
&lt;col&gt;
&lt;col&gt;
&lt;/colgroup&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Aspect&lt;/p&gt;&lt;/th&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Bankr in Clanker (V4, current)&lt;/p&gt;&lt;/th&gt;
&lt;th colspan="1" rowspan="1"&gt;&lt;p&gt;Bankr in Doppler (Decay, current)&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;DEX&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Uniswap V4&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Uniswap V4&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Tick Range&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;[-230,400 → -120,000]&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;[-230,000 → -120,000]&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Mcap Range&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;~$26.7K → ~$1.66B&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;~$27.7K → ~$1.66B&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Fee&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;1.2% (static, can add a volatility hook that rises it up to 5% depending on market conditions)&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;80% → 1.2% (10s linear decay)&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Anti-Snipe&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Dedicated MEV module&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Fee decay (80% for first 10s)&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Curves&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;1 (single concentrated range)&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;2 (99%/1% split)&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Tick Spacing&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;200&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;200&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;External LPs&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Allowed&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Blocked by hook&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The tick ranges are nearly identical, both platforms now target the same ~$27K → ~$1.66B market cap corridor.&lt;/p&gt;

&lt;h3&gt;
  
  
  Current Trading Implications
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The "cliff edge at $205K" no longer applies to new Bankr deployments, the concentrated range now extends to ~$1.66B&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Anti-snipe via fee decay is aggressive: buying in the first 10 seconds costs up to 80%&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The safety-net tail (1% of supply beyond $1.66B) means there's &lt;em&gt;some&lt;/em&gt; liquidity above the concentrated range. Clanker allows adding liquidity on arbitrary ranges after token deployment.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Bankr's migration to Doppler represents a shift in infrastructure philosophy.&lt;/p&gt;

&lt;p&gt;Both Clanker and Doppler are professional-grade systems, Clanker is backed by Farcaster/Neynar, has processed billions in volume, and its v4 now offers similar features including custom curves (up to 7 positions), dynamic fees, and MEV protection.&lt;/p&gt;

&lt;p&gt;The key differences are economic: Clanker protocol fees are significantly higher than Doppler's. Doppler also offers richer token primitives (DERC20 with built-in governance, vesting, and inflation controls) and more granular curve design flexibility through its multicurve architecture.&lt;/p&gt;

&lt;p&gt;The current setup concentrates 99% of liquidity in a ~$27K–$1.66B range with a 1% safety net above. Combined with aggressive anti-snipe fees (80% decaying to 1.2% over 10 seconds) and no external LP access, the design prioritizes fee capture from active trading while providing reasonable depth acraoss a wide mcap range.&lt;/p&gt;

&lt;p&gt;Trade accordingly.&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Doppler App: &lt;a href="https://app.doppler.lol/" rel="noopener noreferrer"&gt;https://app.doppler.lol/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Doppler Docs: &lt;a href="https://docs.doppler.lol/" rel="noopener noreferrer"&gt;https://docs.doppler.lol/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Doppler GitHub: &lt;a href="https://github.com/whetstoneresearch/doppler" rel="noopener noreferrer"&gt;https://github.com/whetstoneresearch/doppler&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bankr Announcement: &lt;a href="https://x.com/i/status/2021103152246775936" rel="noopener noreferrer"&gt;https://x.com/i/status/2021103152246775936&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>defi</category>
      <category>ethereum</category>
      <category>web3</category>
      <category>blockchain</category>
    </item>
  </channel>
</rss>
