<?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</title>
    <description>The most recent home feed on DEV Community.</description>
    <link>https://dev.to</link>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed"/>
    <language>en</language>
    <item>
      <title>A Developer's Checklist for Evaluating B2B Email Marketing Software published: false</title>
      <dc:creator>Siva Devaki</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:37:47 +0000</pubDate>
      <link>https://dev.to/sivadevaki121212/a-developers-checklist-for-evaluating-b2b-email-marketing-softwarepublished-false-4mae</link>
      <guid>https://dev.to/sivadevaki121212/a-developers-checklist-for-evaluating-b2b-email-marketing-softwarepublished-false-4mae</guid>
      <description>&lt;p&gt;Has marketing ever asked you to "just connect" a new email tool to the CRM by Friday?&lt;/p&gt;

&lt;p&gt;B2B email marketing software usually gets picked by marketing and wired up by engineering. The demo covers templates and dashboards. The questions that decide whether the rollout works sit lower in the stack.&lt;/p&gt;

&lt;p&gt;I'm Siva, founder of MassMailer, a native Salesforce app for bulk email. I spend a lot of time on these questions with admins and developers. Here's the checklist I'd hand any developer pulled into an email platform evaluation.&lt;/p&gt;

&lt;p&gt;Start with the part that decides whether mail lands at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Can it authenticate mail from your own domain?
&lt;/h2&gt;

&lt;p&gt;B2B email marketing software must send authenticated mail from your own domain, because mailbox providers now reject or rate limit unauthenticated bulk mail. &lt;a href="https://support.google.com/mail/answer/81126?hl=en" rel="noopener noreferrer"&gt;Gmail's sender guidelines&lt;/a&gt; require three DNS-based checks from bulk senders:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SPF (Sender Policy Framework):&lt;/strong&gt; Lists the servers allowed to send mail for your domain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DKIM (DomainKeys Identified Mail):&lt;/strong&gt; Signs each message with a key published in DNS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DMARC (Domain-based Message Authentication, Reporting, and Conformance):&lt;/strong&gt; Tells receivers how to handle failures and where to send reports.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ask the vendor which records you'll publish and whether DKIM signs with your domain or theirs. Here's the usual shape:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;; SPF: authorize the platform's servers (the include value comes from your vendor)
example.com.                TXT  "v=spf1 include:_spf.your-esp.example ~all"

; DKIM: public key published under the vendor's selector
s1._domainkey.example.com.  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqh..."

; DMARC: start in monitoring mode and collect aggregate reports
_dmarc.example.com.         TXT  "v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A domain can publish only one SPF record, so merge the vendor's include into your existing one. Many vendors hand you CNAME records for DKIM instead, which lets them rotate keys for you. Starting DMARC at &lt;code&gt;p=none&lt;/code&gt; is fine, since Gmail accepts a policy of none for its requirements. Alignment still matters, though. The domain in your From header has to match the SPF or DKIM domain for DMARC to pass.&lt;/p&gt;

&lt;p&gt;Once mail authenticates, the next requirement lives in the message headers.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Does it support one-click unsubscribe?
&lt;/h2&gt;

&lt;p&gt;Bulk email to Gmail needs one-click unsubscribe as defined in RFC 8058, which lets mailbox providers show their own unsubscribe button. Gmail lists it as a requirement for senders above 5,000 messages a day. Each marketing message carries two headers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="na"&gt;List-Unsubscribe: &amp;lt;https://example.com/unsubscribe?token&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;8f3c2a&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;mailto&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;unsubscribe&lt;/span&gt;@&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="n"&gt;subject&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;unsubscribe&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="na"&gt;List-Unsubscribe-Post: List-Unsubscribe&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;One&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Click&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a recipient clicks, the mailbox provider sends an HTTPS POST to that URL with &lt;code&gt;List-Unsubscribe=One-Click&lt;/code&gt; as the body. &lt;a href="https://datatracker.ietf.org/doc/html/rfc8058" rel="noopener noreferrer"&gt;RFC 8058&lt;/a&gt; also requires a valid DKIM signature covering both headers. Questions for the vendor:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does the platform add both headers to every marketing send?&lt;/li&gt;
&lt;li&gt;Is the token unique per recipient, so the POST needs no login or confirmation page?&lt;/li&gt;
&lt;li&gt;How quickly does an unsubscribe write back to the CRM record?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last question leads straight into how the platform shares data with your other systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. How does engagement data get back to your systems?
&lt;/h2&gt;

&lt;p&gt;Good B2B email marketing software pushes every engagement event to your systems as it happens. Sales cares most here, since a click on a pricing email is a buying signal. Polling a reporting API once an hour lets that signal go stale.&lt;/p&gt;

&lt;p&gt;If the vendor offers webhooks, test how they behave when things go wrong:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Retries:&lt;/strong&gt; How long does the platform retry when your endpoint returns a 5xx?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ordering:&lt;/strong&gt; Can a &lt;code&gt;click&lt;/code&gt; event arrive before its &lt;code&gt;delivered&lt;/code&gt; event?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Duplicates:&lt;/strong&gt; Does each event carry a unique ID you can deduplicate on?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Signing:&lt;/strong&gt; Are payloads signed so you can verify where they came from?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's a minimal receiver that verifies a signature and ignores duplicate deliveries. Header names and signing schemes vary by vendor, so treat it as a pattern.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;crypto&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"node:crypto"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;express&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"express"&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&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;seen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&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;// use a table with a unique index in production&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/webhooks/email"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/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="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;res&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;expected&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;crypto&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createHmac&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"sha256"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;WEBHOOK_SECRET&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&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;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&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;received&lt;/span&gt; &lt;span class="o"&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;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"X-Signature"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s2"&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;valid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
    &lt;span class="n"&gt;received&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="n"&gt;expected&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;&amp;amp;&amp;amp;&lt;/span&gt;
    &lt;span class="n"&gt;crypto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timingSafeEqual&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;received&lt;/span&gt;&lt;span class="p"&gt;)&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;expected&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;valid&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&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;event&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="n"&gt;req&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&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;id&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendStatus&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="c1"&gt;// duplicate delivery&lt;/span&gt;

  &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&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;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// enqueue the CRM update here instead of doing it inline&lt;/span&gt;
  &lt;span class="k"&gt;return&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;sendStatus&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="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;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3000&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;Acknowledge fast and do the CRM write from a queue. A slow handler triggers retries, and retries create the duplicates you just filtered out.&lt;/p&gt;

&lt;p&gt;Some platforms skip the webhook layer completely, which brings up the question of where your contacts actually live.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Where does the contact data live?
&lt;/h2&gt;

&lt;p&gt;B2B email marketing software either keeps its own copy of your contacts or reads them directly from your CRM. A separate copy means a sync job and field mappings to maintain. Each mapping is a place where an unsubscribe or a lead status can drift between systems.&lt;/p&gt;

&lt;p&gt;Native CRM apps take the other route. They run inside the CRM and read records directly, so there's no sync job to own. They still have to respect the CRM's own limits. Salesforce, for example, caps &lt;a href="https://help.salesforce.com/s/articleView?language=en_US&amp;amp;id=sales.limitations_email_mass.htm&amp;amp;type=5" rel="noopener noreferrer"&gt;mass and list email at 5,000 external addresses per day&lt;/a&gt; per org. At MassMailer we send through our own infrastructure to get past that cap, while engagement still lands on the Salesforce record.&lt;/p&gt;

&lt;p&gt;Either model can work. What matters is knowing which failure modes you're signing up for before you test the API itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. What do the API and rate limits look like?
&lt;/h2&gt;

&lt;p&gt;Before signing, confirm the platform's API covers the jobs you'll automate and that its rate limits fit your volume. A short test plan in a sandbox account helps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a contact, add it to a list, and trigger a send entirely through the API.&lt;/li&gt;
&lt;li&gt;Bulk import 50,000 test records and time how long the job takes.&lt;/li&gt;
&lt;li&gt;Hit the rate limit on purpose and check for a &lt;code&gt;429&lt;/code&gt; response with a &lt;code&gt;Retry-After&lt;/code&gt; header.&lt;/li&gt;
&lt;li&gt;Export the suppression list and confirm it includes both bounces and unsubscribes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ask whether the vendor offers a test mode, since real sends to fake addresses can hurt your sender reputation. An afternoon of testing here saves weeks of workarounds after launch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bringing it back to the buying decision
&lt;/h2&gt;

&lt;p&gt;Marketing will judge B2B email marketing software on templates and reporting, and engineering should judge it on these five checks. Share your findings before the contract is signed, while the vendor still has a reason to answer quickly.&lt;/p&gt;

&lt;p&gt;If your company runs on Salesforce, I've compared &lt;a href="https://massmailer.io/blog/b2b-email-marketing-software/" rel="noopener noreferrer"&gt;eight B2B email marketing software options by CRM fit&lt;/a&gt;. It pairs well with the checks above.&lt;/p&gt;

&lt;p&gt;What did I miss? Drop the checks your own team runs in the comments.&lt;/p&gt;

</description>
      <category>email</category>
      <category>salesforce</category>
      <category>api</category>
      <category>webdev</category>
    </item>
    <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>Docs first, then code: how Watcher features avoid silent drift</title>
      <dc:creator>Apogee Watcher</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:37:20 +0000</pubDate>
      <link>https://dev.to/apogeewatcher/docs-first-then-code-how-watcher-features-avoid-silent-drift-2685</link>
      <guid>https://dev.to/apogeewatcher/docs-first-then-code-how-watcher-features-avoid-silent-drift-2685</guid>
      <description>&lt;p&gt;When we opened Apogee Watcher to AI coding agents as well as humans, we worried less about broken merges than about features that shipped cleanly while the plan, the schema note, and the support answer quietly disagreed. The product looked finished in the pull request. Marketing still described last month’s behaviour. Support answered from a wiki page nobody had touched.&lt;/p&gt;

&lt;p&gt;So we made the wiki the gate before code moves. Before anyone edits Laravel on the develop branch, the task has to name its governing doc, pull the constraints that already live there, and treat write-back as part of done. That habit is docs-driven delivery: a short ritual that keeps a multi-tenant PageSpeed SaaS from drifting into two truths (the one in git, and the one everyone else still believes). Most tickets need a named wiki home and a constraint list, not a novel-length design document.&lt;/p&gt;

&lt;h2&gt;
  
  
  What docs-first means for a Laravel SaaS (not a novel)
&lt;/h2&gt;

&lt;p&gt;Docs-first, here, means the wiki is the source of truth for product behaviour before the first line of application code moves. A Watcher change almost always already has a home: product and architecture notes, database and server paths, marketing voice, or the public docs agencies actually read. The job is to map the ticket to that file, not to invent a parallel brainstorm in chat.&lt;/p&gt;

&lt;p&gt;What we extract before coding is concrete: paths, components, data fields, tone, quota rules, multi-tenant boundaries. Those constraints become the acceptance bar for the pull request. If the wiki says PageSpeed jobs honour organisation quotas and scheduled discovery, the implementation does not invent a one-off path that skips them. If the branding guide names Victor Mono and the orange/charcoal palette, a new Blade screen does not quietly ship a different typeface “just for this screen.”&lt;/p&gt;

&lt;p&gt;That is documentation-first development as an engineering gate, not README theatre. The README still matters for install. The wiki matters for what stays true after the merge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why silent feature drift shows up when the plan stays stale
&lt;/h2&gt;

&lt;p&gt;Silent drift starts when a change “works” and the plan is left for later. Agents are especially good at that pattern: they can implement a green path, leave a plausible commit message, and never open the governing doc. Humans do the same under deadline pressure. The ticket closes. The schema note still describes the old column. Support still pastes the old steps.&lt;/p&gt;

&lt;p&gt;The cost shows up outside engineering. An agency lead asks whether multi-site schedules include sitemap discovery, and the answer depends on who they ask. A changelog claims a reporting change that marketing has not mirrored. A buyer who already knows &lt;a href="https://apogeewatcher.com/blog/what-is-automated-web-performance-monitoring?utm_source=hashnode&amp;amp;utm_medium=referral&amp;amp;utm_campaign=docs-first-then-code-watcher-features-avoid-silent-drift" rel="noopener noreferrer"&gt;what automated web performance monitoring&lt;/a&gt; means looks for that behaviour in the app and finds a half-updated screen.&lt;/p&gt;

&lt;p&gt;A stale wiki is enough to produce those failures; you do not need a production outage. We treat the mismatch as a product defect: a SaaS that sells continuous monitoring rather than one-off audits sells trust with every schedule, so the next support thread becomes the regression report when written truth and running truth diverge.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the docs-driven delivery loop runs on develop
&lt;/h2&gt;

&lt;p&gt;The loop is short enough to copy into another team’s checklist this week.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Map the task&lt;/strong&gt; to one or more governing wiki docs (product plan, database notes, server paths, marketing, branding). If no doc fits, that is a signal: the feature has no home yet, so write the thin constraint page before coding.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extract constraints&lt;/strong&gt; into working notes: fields, paths, tone, quota and tenancy rules, UI patterns. Those become the review checklist.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Implement on develop / the shared development host&lt;/strong&gt;, following the documented patterns. We do not treat a local Dropbox mirror as the source of truth for application commits; the development environment and the develop branch do.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write behaviour back&lt;/strong&gt; into the same wiki docs before the work is called done. New conventions, changed jobs, updated screens, and “what support should say” belong in the file the next agent or human will open.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Post-change hygiene on the development host (cleared views, rebuilt assets when classes change, careful tests that do not wipe the shared database) sits beside that loop, so the next person inherits an updated plan instead of reverse-engineering the last merge. Branch discipline is a sibling habit: fixes land on develop before production. The docs loop keeps that branch from becoming a museum of undocumented behaviour. When the next feature has nowhere to hang in the wiki, create the home first. That is cheaper than teaching support a surprise.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docs-first versus fix production then document later
&lt;/h2&gt;

&lt;p&gt;The opposite habit looks efficient for a day. Someone patches production, pastes a screenshot into Slack, and promises to “update the docs tomorrow.” Tomorrow never arrives with the same detail. The next agent reads the old wiki, reintroduces the bug, or ships a UI that contradicts the patch. Support keeps answering from the stale page, because that is what search finds.&lt;/p&gt;

&lt;p&gt;Docs-first flips the order: constraints first, code second, write-back before done. It feels slower on a one-line fix. Across a month of agent-assisted pull requests it is faster, because each change leaves a trail the next change can trust. We would rather ship one fewer surprise feature than explain why the app and the help article disagree.&lt;/p&gt;

&lt;p&gt;For the buyer-facing side of that honesty, the Watcher guide on &lt;a href="https://apogeewatcher.com/blog/how-to-set-up-automated-pagespeed-monitoring-for-multiple-sites?utm_source=hashnode&amp;amp;utm_medium=referral&amp;amp;utm_campaign=docs-first-then-code-watcher-features-avoid-silent-drift" rel="noopener noreferrer"&gt;how to set up automated PageSpeed monitoring for multiple sites&lt;/a&gt; is the operational companion, because definition and setup stay aligned only when the wiki and the public posts move together.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Is this the same as writing a long design document for every ticket?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
No. Most Watcher tasks map to an existing wiki file and a short constraint list. The novel-length design doc is the exception. The rule is “name the governing doc and write behaviour back,” not “produce a ten-page RFC.”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does docs-first replace code review or tests?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
No. Review and tests still catch logic bugs. Docs-first catches a different class of failure: behaviour that is correct in git and wrong in every human-facing artefact. Both gates matter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What if the wiki is wrong?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Fix the wiki as part of the same change, or open a short task that corrects it before you encode the wrong constraint. Shipping code against a known-bad plan just hardens the drift.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does this relate to refusing production hotfixes?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Hotfix policy is about &lt;em&gt;where&lt;/em&gt; code lands (develop and the development host before production). Docs-driven delivery is about &lt;em&gt;what&lt;/em&gt; must stay true when that code lands. They reinforce each other; they are not the same ritual.&lt;/p&gt;

&lt;h2&gt;
  
  
  Map the next feature to a wiki home before you open the editor
&lt;/h2&gt;

&lt;p&gt;If you run a Laravel SaaS with humans and agents in the same repository, pick one upcoming feature and force the loop once: governing doc, extracted constraints, develop-branch implementation, write-back before merge. Skipping the loop rarely fails the build; it leaves a support answer that contradicts the app, and a buyer who trusted the public definition of &lt;a href="https://apogeewatcher.com/blog/what-is-automated-web-performance-monitoring?utm_source=hashnode&amp;amp;utm_medium=referral&amp;amp;utm_campaign=docs-first-then-code-watcher-features-avoid-silent-drift" rel="noopener noreferrer"&gt;automated web performance monitoring&lt;/a&gt; until the product quietly moved.&lt;/p&gt;

&lt;p&gt;For the agency-facing setup path that should stay in sync, start from &lt;a href="https://apogeewatcher.com/blog/how-to-set-up-automated-pagespeed-monitoring-for-multiple-sites?utm_source=hashnode&amp;amp;utm_medium=referral&amp;amp;utm_campaign=docs-first-then-code-watcher-features-avoid-silent-drift" rel="noopener noreferrer"&gt;how to set up automated PageSpeed monitoring for multiple sites&lt;/a&gt; and keep the definition post beside it, so “automated monitoring” still means the same thing in marketing and in the app even after the next agent-assisted merge.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://apogeewatcher.com/blog/how-to-set-up-automated-pagespeed-monitoring-for-multiple-sites" rel="noopener noreferrer"&gt;How to Set Up Automated PageSpeed Monitoring for Multiple Sites&lt;/a&gt; (Apogee Watcher)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://apogeewatcher.com/blog/what-is-automated-web-performance-monitoring" rel="noopener noreferrer"&gt;What Is Automated Web Performance Monitoring?&lt;/a&gt; (Apogee Watcher)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>saas</category>
      <category>webdev</category>
      <category>webperf</category>
    </item>
    <item>
      <title>Natural/Adabas to Java: 7 Hidden Risks in Legacy Code Conversion</title>
      <dc:creator>Dhruv Joshi</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:37:18 +0000</pubDate>
      <link>https://dev.to/quokkalabs/naturaladabas-to-java-7-hidden-risks-in-legacy-code-conversion-4b4p</link>
      <guid>https://dev.to/quokkalabs/naturaladabas-to-java-7-hidden-risks-in-legacy-code-conversion-4b4p</guid>
      <description>&lt;p&gt;South Carolina PEBA's &lt;a href="https://usesettle.com/rfp-hunter/code-conversion-database-modernization-r1ob" rel="noopener noreferrer"&gt;2026 Natural/Adabas modernization procurement&lt;/a&gt; exposes an uncomfortable truth: converting legacy code into Java is becoming easier. Proving that the converted application won't miscalculate retirement benefits, corrupt records, or break critical transactions remains the real engineering challenge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Natural/Adabas to Java Migration Is More Than Code Conversion
&lt;/h2&gt;

&lt;p&gt;Natural/Adabas to Java migration involves transforming Natural application logic, Adabas database structures, transaction boundaries, batch processes, and business rules into a modern Java environment. Successful migration requires behavioral equivalence, meaning the modernized application produces equivalent business outcomes under identical inputs, failure conditions, and operational constraints.&lt;/p&gt;

&lt;p&gt;For enterprises evaluating &lt;a href="https://quokkalabs.com/application-modernization-services?utm_source=dev.to&amp;amp;utm_medium=blog&amp;amp;utm_campaign=dhruv"&gt;legacy application modernization services&lt;/a&gt;, the percentage of converted code is a poor substitute for verified functional accuracy.&lt;/p&gt;

&lt;p&gt;Here are seven risks developers and enterprise architects should address before production deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  7 Hidden Risks in Natural/Adabas to Java Code Conversion
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Silent Business Logic Changes
&lt;/h3&gt;

&lt;p&gt;Natural applications frequently contain undocumented rules inside subprograms, shared data areas, processing loops, and exception handlers.&lt;/p&gt;

&lt;p&gt;Automated conversion can preserve syntax while changing business behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample failure:&lt;/strong&gt; A converted Java application applies an eligibility rule before calculating service credits instead of afterward. Both implementations compile successfully, but their retirement benefit calculations differ.&lt;/p&gt;

&lt;h4&gt;
  
  
  Prevention strategy
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Extract business rules independently of generated Java code.&lt;/li&gt;
&lt;li&gt;Capture existing application outputs as regression fixtures.&lt;/li&gt;
&lt;li&gt;Test boundary conditions and historical exceptions.&lt;/li&gt;
&lt;li&gt;Trace converted methods back to original Natural programs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Treat business-rule verification as a mandatory deliverable in legacy system modernization.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Adabas-to-SQL Data Structure Mismatches
&lt;/h3&gt;

&lt;p&gt;Adabas supports multiple-value fields (MU) and periodic groups (PE), which do not map directly to conventional relational database structures.&lt;/p&gt;

&lt;p&gt;Flattening these structures can silently destroy relationships between historical records.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample failure:&lt;/strong&gt; A member has three historical employment periods. An incorrect SQL transformation preserves the latest period but loses two previous records.&lt;/p&gt;

&lt;p&gt;The migration reports matching member counts while historical information disappears.&lt;/p&gt;

&lt;h4&gt;
  
  
  Prevention strategy
&lt;/h4&gt;

&lt;p&gt;Preserve occurrence numbers, parent-child relationships, internal sequence number mappings, and historical ordering.&lt;/p&gt;

&lt;p&gt;Validate both record counts and individual field values. The &lt;a href="https://documentation.softwareag.com/naturalONE/natONE921/webhelp/one-webhelp/natmf/pg/pg_dbms_ada.htm" rel="noopener noreferrer"&gt;Adabas database documentation&lt;/a&gt; provides important context for these structures.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Transaction Boundaries and Record Locking Failures
&lt;/h3&gt;

&lt;p&gt;Natural's &lt;code&gt;END TRANSACTION&lt;/code&gt; and &lt;code&gt;BACKOUT TRANSACTION&lt;/code&gt; statements define transaction behavior that Java developers must deliberately reproduce.&lt;/p&gt;

&lt;p&gt;Adding Spring's &lt;code&gt;@Transactional&lt;/code&gt; annotation does not automatically preserve legacy commit boundaries, record holds, or recovery semantics.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample failure:&lt;/strong&gt; A payment update succeeds, but its corresponding account update fails. Incorrect transaction boundaries leave financial records inconsistent.&lt;/p&gt;

&lt;h4&gt;
  
  
  Prevention strategy
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Map every legacy commit and rollback boundary.&lt;/li&gt;
&lt;li&gt;Verify transaction isolation and lock behavior.&lt;/li&gt;
&lt;li&gt;Inject failures between dependent database operations.&lt;/li&gt;
&lt;li&gt;Test concurrent updates against the same record.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Effective software product modernization services must treat transaction equivalence as an architectural requirement.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://documentation.softwareag.com/natmf/9.2.3/en/webhelp/natmf-webhelp/sm/endtrans.htm" rel="noopener noreferrer"&gt;Natural transaction documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Decimal Precision and Rounding Errors
&lt;/h3&gt;

&lt;p&gt;Java floating-point arithmetic can introduce discrepancies when replacing Natural fixed-decimal financial calculations.&lt;/p&gt;

&lt;p&gt;Consider this Java example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// 0.30000000000000004&lt;/span&gt;

&lt;span class="nc"&gt;BigDecimal&lt;/span&gt; &lt;span class="n"&gt;total&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;BigDecimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"0.1"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BigDecimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"0.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="nc"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// 0.3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using &lt;code&gt;BigDecimal&lt;/code&gt; helps preserve decimal precision, but developers must also reproduce legacy rounding, truncation, scale, and intermediate calculation behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample failure:&lt;/strong&gt; Thousands of individually insignificant rounding differences create a financial reconciliation discrepancy.&lt;/p&gt;

&lt;h4&gt;
  
  
  Prevention strategy
&lt;/h4&gt;

&lt;p&gt;Require exact financial reconciliation for deterministic calculations, including negative amounts, maximum values, and rounding boundaries.&lt;/p&gt;

&lt;p&gt;See the &lt;a href="https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/math/BigDecimal.html" rel="noopener noreferrer"&gt;Java BigDecimal documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Query Semantics and Performance Regression
&lt;/h3&gt;

&lt;p&gt;Natural database operations such as &lt;code&gt;FIND&lt;/code&gt; and &lt;code&gt;READ&lt;/code&gt; rely on Adabas-specific access behavior.&lt;/p&gt;

&lt;p&gt;For example, &lt;a href="https://documentation.softwareag.com/naturalONE/natONE912/natov/sm/read.htm" rel="noopener noreferrer"&gt;Natural READ documentation&lt;/a&gt; explains how multiple-value descriptors can cause repeated record reads and how null suppression affects record selection.&lt;/p&gt;

&lt;p&gt;A superficially equivalent SQL query may return different results.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample failure:&lt;/strong&gt; A Java batch process generates different payment records because its SQL query changes the legacy processing order.&lt;/p&gt;

&lt;h4&gt;
  
  
  Prevention strategy
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Verify selection, ordering, and duplicate-handling behavior.&lt;/li&gt;
&lt;li&gt;Inspect SQL execution plans.&lt;/li&gt;
&lt;li&gt;Detect excessive database queries generated by ORM frameworks.&lt;/li&gt;
&lt;li&gt;Benchmark representative production workloads.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Set measurable performance requirements before choosing the target database architecture.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Hidden Batch Dependencies and Restart Failures
&lt;/h3&gt;

&lt;p&gt;Legacy systems extend beyond application source code.&lt;/p&gt;

&lt;p&gt;Job schedules, external files, reporting utilities, execution sequences, and restart checkpoints often determine whether critical business processes complete correctly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample failure:&lt;/strong&gt; A Java payment batch crashes after processing 60% of its records. Restarting the entire job generates duplicate payments.&lt;/p&gt;

&lt;h4&gt;
  
  
  Prevention strategy
&lt;/h4&gt;

&lt;p&gt;Implement durable checkpoints, duplicate-prevention controls, dependency mapping, and restart testing.&lt;/p&gt;

&lt;p&gt;For organizations introducing automated monitoring, &lt;a href="https://quokkalabs.com/ai-workflow-automation-services?utm_source=dev.to&amp;amp;utm_medium=blog&amp;amp;utm_campaign=dhruv"&gt;ai workflow automation services&lt;/a&gt; can support exception routing and reconciliation workflows without replacing deterministic financial controls.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. AI-Generated Code and Security Regressions
&lt;/h3&gt;

&lt;p&gt;AI can accelerate Natural-to-Java translation, but generated code can introduce authorization gaps, unsafe database queries, dependency vulnerabilities, and incorrect assumptions about undocumented business rules.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample failure:&lt;/strong&gt; A converted API authenticates users but fails to verify whether they can access another member's retirement information.&lt;/p&gt;

&lt;h4&gt;
  
  
  Prevention strategy
&lt;/h4&gt;

&lt;p&gt;Require human-reviewed authorization tests, dependency scanning, code traceability, and automated security checks.&lt;/p&gt;

&lt;p&gt;Use &lt;a href="https://quokkalabs.com/ai-security-services?utm_source=dev.to&amp;amp;utm_medium=blog&amp;amp;utm_campaign=dhruv"&gt;trustworthy ai security services&lt;/a&gt; where generated code requires additional security validation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quokka Labs' Code-Conversion Risk Register
&lt;/h2&gt;

&lt;p&gt;The following proposed engineering framework converts migration risks into measurable release conditions.&lt;/p&gt;

&lt;p&gt;These are illustrative test cases, not findings from a PEBA implementation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sample risk cases and acceptance criteria
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;NC-01 — Business logic | Critical:&lt;/strong&gt; Historical eligibility exception. Gate: identical approved business decisions. Owner: domain lead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NC-02 — Data integrity | Critical:&lt;/strong&gt; Repeating employment records. Gate: zero unexplained missing occurrences. Owner: data engineer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NC-03 — Transactions | Critical:&lt;/strong&gt; Failure between dependent updates. Gate: expected rollback behavior. Owner: Java architect.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NC-04 — Precision | Critical:&lt;/strong&gt; Decimal rounding boundary. Gate: exact expected financial result. Owner: QA lead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NC-05 — Performance | High:&lt;/strong&gt; Peak-volume database processing. Gate: agreed workload and latency targets. Owner: performance engineer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NC-06 — Batch recovery | Critical:&lt;/strong&gt; Interrupted payment processing. Gate: zero duplicate payments. Owner: platform engineer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NC-07 — Security | Critical:&lt;/strong&gt; Unauthorized member-record access. Gate: every prohibited request rejected. Owner: security lead.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unresolved critical failures should block production cutover.&lt;/p&gt;

&lt;p&gt;This is where software modernization expertise becomes measurable rather than promotional.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Should Enterprises Evaluate Legacy Application Modernization Services?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Establish evidence before approving production migration
&lt;/h3&gt;

&lt;p&gt;A reliable Natural/Adabas-to-Java migration should include parallel execution, field-level database reconciliation, business-rule regression tests, transaction failure simulations, security verification, and production-scale performance testing. Enterprises should approve migration based on documented acceptance criteria rather than converted lines of code, compilation rates, or AI-generated confidence scores.&lt;/p&gt;

&lt;p&gt;Quokka Labs recommends validating a representative workload before expanding migration scope.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can AI completely automate Natural-to-Java conversion?
&lt;/h3&gt;

&lt;p&gt;AI can automate portions of Natural-to-Java conversion, including source analysis, code generation, documentation, and test creation. However, it cannot independently guarantee business-rule accuracy, transaction equivalence, data integrity, or authorization correctness. Human engineering review and comparison against verified legacy behavior remain essential for production-critical enterprise applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is automated conversion better than a complete rewrite?
&lt;/h3&gt;

&lt;p&gt;Automated conversion is useful when preserving established business behavior is the primary requirement. A rewrite may be preferable when business processes or architectural requirements need substantial changes. Many legacy system modernization projects benefit from combining controlled conversion with selective refactoring, provided both approaches are supported by measurable acceptance tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Modernize the System, Not Just the Source Code
&lt;/h2&gt;

&lt;p&gt;The strongest modernization outcome is not Java code that compiles. It is a maintainable application that preserves critical business outcomes and can evolve safely.&lt;/p&gt;

&lt;p&gt;Quokka Labs combines application modernization services with AI-assisted engineering and evidence-driven validation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Planning a Natural/Adabas migration?&lt;/strong&gt; &lt;a href="https://quokkalabs.com/?utm_source=dev.to&amp;amp;utm_medium=blog&amp;amp;utm_campaign=dhruv"&gt;Discuss your code-conversion requirements with Quokka Labs&lt;/a&gt; before committing to a migration architecture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For DEV Community engineers:&lt;/strong&gt; Which would block your production migration first: incorrect business logic, silent data loss, or broken transaction recovery? Share your experience in the comments.&lt;/p&gt;

</description>
      <category>java</category>
      <category>adabas</category>
      <category>natural</category>
      <category>code</category>
    </item>
    <item>
      <title>Bahmni's CSV importer must not let admin input choose the destination path</title>
      <dc:creator>johnettwawers</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:37:15 +0000</pubDate>
      <link>https://dev.to/johnettwawers/bahmnis-csv-importer-must-not-let-admin-input-choose-the-destination-path-1695</link>
      <guid>https://dev.to/johnettwawers/bahmnis-csv-importer-must-not-let-admin-input-choose-the-destination-path-1695</guid>
      <description>&lt;h1&gt;
  
  
  Bahmni's CSV importer must not let admin input choose the destination path
&lt;/h1&gt;

&lt;p&gt;Bahmni patched a path-traversal issue in the admin CSV import flow tracked as CVE-2026-63194. The affected module is &lt;code&gt;bahmnicore-omod&lt;/code&gt; 0.93 and later, with fixed releases in 0.93.1, 1.0.1, 1.1.1, 1.2.1, 1.3.1, and 2.0.1. The advisory describes insufficient validation of input paths that may allow an arbitrary file write.&lt;/p&gt;

&lt;h2&gt;
  
  
  The import worker has too much authority
&lt;/h2&gt;

&lt;p&gt;CSV import is a normal administrative operation. A hospital may load patient, reference, or integration data from a supplier. If the importer builds a filesystem path from input and writes with the application server's account, a crafted path can move the write outside the intended staging directory.&lt;/p&gt;

&lt;p&gt;The attacker's benefit depends on what the server process can reach. A write to an executable web directory, a scheduled-task location, or an application configuration path can become a stronger compromise. Even a write outside the upload folder can overwrite a business file and cause data loss. The advisory does not claim that every deployment has a direct remote-code-execution path, and an analyst should not invent one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Restrict the route and the filesystem
&lt;/h2&gt;

&lt;p&gt;Apply the fixed module version. Until the update is in place, restrict &lt;code&gt;/openmrs/ws/rest/v1/bahmnicore/admin/upload/*&lt;/code&gt; at the ingress or reverse proxy to trusted addresses. Remove Admin Page access for nonessential users and review who can reach the backend API directly.&lt;/p&gt;

&lt;p&gt;The application server should write imports to a dedicated directory with no execute permission and no path to configuration files. Canonicalize the final path and verify that it stays below the import root. Run the importer with a low-privilege OS identity. Use an allow-list of expected CSV names and reject absolute paths, parent-directory sequences, and alternate encodings that resolve outside the root.&lt;/p&gt;

&lt;h2&gt;
  
  
  Monitor the upload path
&lt;/h2&gt;

&lt;p&gt;Log the authenticated user, uploaded filename, resolved destination, file hash, and import result. Alert on files written outside the normal import directory, failed path validation, unexpected file types, and writes followed by a process restart. Review administrative sessions around any suspicious write.&lt;/p&gt;

&lt;p&gt;The investigation should preserve the original upload, server-side path, file ownership, access time, and any web requests for the newly written file. If the import account has access to shared storage, inspect the shares for new or modified content.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verify with a non-production import
&lt;/h2&gt;

&lt;p&gt;Test with a CSV that contains safe path variations and confirm that every write remains under the expected root. Confirm that the application returns a clear validation error without exposing filesystem details. Repeat the test after upgrades and whenever the import library changes.&lt;/p&gt;

&lt;p&gt;The fix is partly a code change and partly a boundary change. Parameter validation stops the crafted path from being accepted. Directory permissions limit the damage if a future validation gap appears.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/bahmni/bahmni-core/security/advisories/GHSA-pmw7-2mfv-4592" rel="noopener noreferrer"&gt;Bahmni GHSA-pmw7-2mfv-4592&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://osv.dev/vulnerability/CVE-2026-63194" rel="noopener noreferrer"&gt;CVE-2026-63194 summary&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>bahmni</category>
      <category>openmrs</category>
      <category>pathtraversal</category>
      <category>csvimport</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>Modeling Two-Phase Payment Holds, Partial Captures, and Releases in Double-Entry SQL</title>
      <dc:creator>Tharusha Nuwansara</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:37:07 +0000</pubDate>
      <link>https://dev.to/tharushanuwansara/modeling-two-phase-payment-holds-partial-captures-and-releases-in-double-entry-sql-cpl</link>
      <guid>https://dev.to/tharushanuwansara/modeling-two-phase-payment-holds-partial-captures-and-releases-in-double-entry-sql-cpl</guid>
      <description>&lt;h2&gt;
  
  
  Why Boolean &lt;code&gt;is_captured&lt;/code&gt; Columns Break on Partial Captures and Voids
&lt;/h2&gt;

&lt;p&gt;Card authorizations, marketplace payouts, and usage-based holds reserve funds (&lt;code&gt;$20.00&lt;/code&gt; held) before final settlement (&lt;code&gt;$14.00&lt;/code&gt; captured, &lt;code&gt;$6.00&lt;/code&gt; released). Tracking this with a single &lt;code&gt;orders(amount, is_captured)&lt;/code&gt; column fails whenever a partial capture, duplicate capture retry, or 7-day authorization expiry void arrives.&lt;/p&gt;

&lt;p&gt;Across production Python services running without dedicated SRE teams or expensive managed middleware, three concrete failure patterns trigger silent data loss, latency stalls, or financial drift whenever this boundary is left unguarded:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Over-Capture Beyond Hold Ceiling:&lt;/strong&gt; Concurrent capture retries settle &lt;code&gt;$14.00&lt;/code&gt; twice against a &lt;code&gt;$20.00&lt;/code&gt; hold without checking remaining uncaptured hold balance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Orphaned Unreleased Holds:&lt;/strong&gt; Partial captures leave &lt;code&gt;$6.00&lt;/code&gt; permanently frozen in reserved liability reports unless explicitly released.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unbalanced Ledger Edits:&lt;/strong&gt; Mutating &lt;code&gt;amount&lt;/code&gt; from &lt;code&gt;2000&lt;/code&gt; down to &lt;code&gt;1400&lt;/code&gt; erases audit history of the original authorization.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this empirical reliability teardown—&lt;em&gt;Tracking authorized funds, partial settlements, and expired hold releases with zero negative-balance race conditions.&lt;/em&gt; (upstream reference: &lt;a href="https://www.sqlite.org/foreignkeys.html" rel="noopener noreferrer"&gt;SQLite Official Specification&lt;/a&gt;)—we design, execute, and verify a self-contained Python 3.11+ standard-library implementation that enforces deterministic invariants under realistic contention and fault injection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture &amp;amp; Invariant Trade-Off Matrix
&lt;/h2&gt;

&lt;p&gt;Before writing implementation code, compare how naive shortcuts behave under failure against the deterministic pattern verified below:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Failure Behavior Under Load / Crash&lt;/th&gt;
&lt;th&gt;Production Guarantee&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Mutable &lt;code&gt;status&lt;/code&gt; + &lt;code&gt;amount&lt;/code&gt; Row&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Cannot represent partial capture + release cleanly&lt;/td&gt;
&lt;td&gt;Over-capture race risk&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Ad-Hoc Balance Counters&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Drifts on retries and partial voids&lt;/td&gt;
&lt;td&gt;Fails audit reconciliation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Double-Entry Hold -&amp;gt; Capture/Release&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Asserts &lt;code&gt;remaining_hold &amp;gt;= capture_cents&lt;/code&gt; inside &lt;code&gt;BEGIN IMMEDIATE&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Zero over-capture, exact conservation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you want drop-in scheduling locks (&lt;code&gt;IdempotentCronRunner&lt;/code&gt;) and HTTP &lt;code&gt;Retry-After&lt;/code&gt; circuit breakers ready to protect your existing scripts today at zero cost, download the &lt;a href="https://whop.com/checkout/plan_rNDWoO6bujfMk/?utm_source=devto&amp;amp;utm_medium=tutorial&amp;amp;utm_campaign=modeling-two-phase-payment-holds-partial-capture&amp;amp;slug=modeling-two-phase-payment-holds-partial-captures-and-releases-in-2d0cf9&amp;amp;sku=free-idempotent-cron-mini-kit" rel="noopener noreferrer"&gt;Free Idempotent Cron &amp;amp; Circuit-Breaker Mini-Kit ($0+ PWYW)&lt;/a&gt; and run its unit tests locally alongside this lesson.&lt;/p&gt;

&lt;h2&gt;
  
  
  Self-Contained Python 3.11+ Implementation &amp;amp; Fault-Injection Benchmark
&lt;/h2&gt;

&lt;p&gt;Every module in this 30-day series uses zero third-party packages (&lt;code&gt;pip install&lt;/code&gt; count = &lt;code&gt;0&lt;/code&gt;) so the exact code below runs cleanly on stock Python 3.11+ across Linux VMs, macOS workstations, and GitHub Actions runners:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;__future__&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;annotations&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sqlite3&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pathlib&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Path&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;open_hold_ledger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;sqlite3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Connection&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sqlite3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;5.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;isolation_level&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;executescript&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s2"&gt;"""
        CREATE TABLE postings (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            auth_id TEXT NOT NULL,
            event_key TEXT NOT NULL,
            account TEXT NOT NULL,
            direction TEXT NOT NULL CHECK (direction IN ('DEBIT', 'CREDIT')),
            cents INTEGER NOT NULL CHECK (cents &amp;gt; 0),
            UNIQUE(event_key, account, direction)
        );
        """&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;conn&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;remaining_hold_cents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;sqlite3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Connection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;auth_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&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;int&lt;/span&gt;&lt;span class="p"&gt;:&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;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s2"&gt;"""
        SELECT COALESCE(SUM(CASE WHEN direction = 'CREDIT' THEN cents ELSE -cents END), 0)
          FROM postings WHERE auth_id = ? AND account = 'auth_hold_liability'
        """&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auth_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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetchone&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="kt"&gt;int&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="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;def&lt;/span&gt; &lt;span class="nf"&gt;authorize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;sqlite3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Connection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;auth_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"BEGIN IMMEDIATE;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;executemany&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s2"&gt;"INSERT INTO postings (auth_id, event_key, account, direction, cents) VALUES (?, ?, ?, ?, ?)"&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;auth_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{auth_id}:auth"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"customer_card_hold"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"DEBIT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cents&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;auth_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{auth_id}:auth"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"auth_hold_liability"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"CREDIT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cents&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;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"COMMIT;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;capture_and_release_rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;sqlite3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Connection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;auth_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;capture_cents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&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;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"BEGIN IMMEDIATE;"&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;rem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;remaining_hold_cents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;auth_id&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;rem&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;capture_cents&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;capture_cents&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&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;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ROLLBACK;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"rejected_insufficient_hold"&lt;/span&gt;
        &lt;span class="n"&gt;rows&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;auth_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"auth_hold_liability"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"DEBIT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;capture_cents&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;auth_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"settled_revenue"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"CREDIT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;capture_cents&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;release_cents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;capture_cents&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;release_cents&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="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extend&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;auth_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{event_key}:rel"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"auth_hold_liability"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"DEBIT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;release_cents&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;auth_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{event_key}:rel"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"customer_card_hold"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"CREDIT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;release_cents&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;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;executemany&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"INSERT INTO postings (auth_id, event_key, account, direction, cents) VALUES (?, ?, ?, ?, ?)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"COMMIT;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"captured_and_released"&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="n"&gt;sqlite3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IntegrityError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ROLLBACK;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"duplicate_event"&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;run_escrow_verification&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="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;t0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;perf_counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;open_hold_ledger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"escrow.db"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;authorize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"auth_100"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;first&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;capture_and_release_rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"auth_100"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"cap_1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1400&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;second_over&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;capture_and_release_rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"auth_100"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"cap_2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1400&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;debits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT SUM(cents) FROM postings WHERE direction='DEBIT'"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetchone&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="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="n"&gt;credits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT SUM(cents) FROM postings WHERE direction='CREDIT'"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetchone&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="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="n"&gt;settled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT SUM(cents) FROM postings WHERE account='settled_revenue'"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetchone&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="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="n"&gt;rem_hold&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;remaining_hold_cents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"auth_100"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;report&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"first_capture"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"second_overcapture_attempt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;second_over&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"settled_revenue_cents"&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="s2"&gt;"remaining_open_hold_cents"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rem_hold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"imbalance_cents"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;debits&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;credits&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"elapsed_ms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;perf_counter&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;t0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;1000.0&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="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"escrow_report.json"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&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="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&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="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;run_escrow_verification&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;Next, we assert our domain invariants against the emitted JSON benchmark report in a separate isolated shell invocation—any silent regression exits non-zero and blocks publication automatically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 -I -c &lt;span class="s1"&gt;'
import json
r = json.load(open("escrow_report.json"))
assert r["first_capture"] == "captured_and_released" and r["second_overcapture_attempt"] == "rejected_insufficient_hold"
assert r["settled_revenue_cents"] == 1400 and r["remaining_open_hold_cents"] == 0 and r["imbalance_cents"] == 0
print(f"Verified two-phase hold/capture ledger: settled={r["settled_revenue_cents"]}c, open_hold={r["remaining_open_hold_cents"]}c, imbalance={r["imbalance_cents"]}c.")
'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Real Captured Execution Output
&lt;/h2&gt;

&lt;p&gt;Every Python and shell block in this article was executed inside a clean isolated sandbox prior to publication. Here is the exact stdout captured from the run above:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Block 1 (python, exit=0, 30.3 ms)
{
  "first_capture": "captured_and_released",
  "second_overcapture_attempt": "rejected_insufficient_hold",
  "settled_revenue_cents": 1400,
  "remaining_open_hold_cents": 0,
  "imbalance_cents": 0,
  "elapsed_ms": 3.02
}

# Block 2 (bash, exit=0, 20.0 ms)
Verified two-phase hold/capture ledger: settled=1400c, open_hold=0c, imbalance=0c.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dissecting the Empirical Benchmark Results
&lt;/h2&gt;

&lt;p&gt;Inspecting the captured metrics above highlights three engineering properties that hold consistently in live deployments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zero Over-Capture Risk:&lt;/strong&gt; Attempting a second &lt;code&gt;1400c&lt;/code&gt; capture after &lt;code&gt;1400c&lt;/code&gt; captured + &lt;code&gt;600c&lt;/code&gt; released saw &lt;code&gt;remaining_hold == 0&lt;/code&gt; inside &lt;code&gt;BEGIN IMMEDIATE&lt;/code&gt; and rejected cleanly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clean Hold Closure:&lt;/strong&gt; Releasing the unused &lt;code&gt;600c&lt;/code&gt; hold alongside the &lt;code&gt;1400c&lt;/code&gt; capture brought &lt;code&gt;auth_hold_liability&lt;/code&gt; cleanly to &lt;code&gt;0&lt;/code&gt; cents.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strict Double-Entry Conservation:&lt;/strong&gt; Total &lt;code&gt;DEBIT&lt;/code&gt; postings equaled total &lt;code&gt;CREDIT&lt;/code&gt; postings (&lt;code&gt;imbalance_cents == 0&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notice how structuring the verification harness around explicit numeric invariants—rather than eyeballs on log lines—turns operational assumptions into fast regression checks that finish in tens of milliseconds on every commit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sweeping Expired Uncaptured Authorizations
&lt;/h3&gt;

&lt;p&gt;Card holds typically expire upstream after 7 days; run a daily reconciliation query finding &lt;code&gt;auth_id&lt;/code&gt;s older than 6.5 days where &lt;code&gt;remaining_hold_cents &amp;gt; 0&lt;/code&gt; and post an explicit &lt;code&gt;'expired_void'&lt;/code&gt; release entry.&lt;/p&gt;

&lt;p&gt;When integrating this pattern into a larger service, keep failure boundaries explicit: validate untrusted inputs before opening write transactions, bound memory and disk growth with deterministic TTL or rollup windows, and emit structured JSON summaries per run so scheduled health checks can alert on anomalies without paid log-ingestion agents. Pairing deterministic local SQLite state with explicit timeout budgets ensures that neither upstream latency spikes nor sudden restarts can leave background workers wedged in partial states or silently drop customer records across deployment rollouts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ship the Complete Zero-Cost Reliability Stack
&lt;/h2&gt;

&lt;p&gt;Building autonomous Python or TypeScript workflows, webhook processors, or SaaS backends without monthly Redis/broker bills? The complete &lt;a href="https://whop.com/tharusha-nuwansara/production-ai-agent-zero-cost-backend-reliability-starter-kit/?utm_source=devto&amp;amp;utm_medium=tutorial&amp;amp;utm_campaign=modeling-two-phase-payment-holds-partial-capture&amp;amp;slug=modeling-two-phase-payment-holds-partial-captures-and-releases-in-2d0cf9&amp;amp;sku=production-agent-automation-kit" rel="noopener noreferrer"&gt;Production AI Agent &amp;amp; Zero-Cost Backend Reliability Starter Kit ($14, MIT License)&lt;/a&gt; bundles the transactional SQLite WAL job queue + dead-letter CLI (&lt;code&gt;wal_queue.py&lt;/code&gt;), Python and Node/TypeScript structured-output circuit breakers, constant-time HMAC webhook guards, portable double-entry SQL ledgers, and 4 production GitHub Actions workflows.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Verification &amp;amp; Disclosure: Published under the **Zero-Cost Production Reliability&lt;/em&gt;* column by &lt;strong&gt;Tharusha Nuwansara&lt;/strong&gt;. Every Python and shell block above was executed and verified inside an isolated &lt;code&gt;python3 -I&lt;/code&gt; sandbox (&lt;code&gt;returncode == 0&lt;/code&gt;) prior to publication.*&lt;/p&gt;

</description>
      <category>sql</category>
      <category>python</category>
      <category>fintech</category>
      <category>backend</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>2 Image APIs for Landscape, Portrait, and Square Output</title>
      <dc:creator>Quinn Tang</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:37:04 +0000</pubDate>
      <link>https://dev.to/maigade/2-image-apis-for-landscape-portrait-and-square-output-32g4</link>
      <guid>https://dev.to/maigade/2-image-apis-for-landscape-portrait-and-square-output-32g4</guid>
      <description>&lt;p&gt;MiniMax’s current image-generation API supports output sizing by width and height or by aspect ratio, while the OpenAI Images API exposes shape-related output controls such as &lt;code&gt;size&lt;/code&gt;. The two approaches differ in how the application states the target frame: MiniMax can calculate dimensions from a named proportion, while OpenAI organizes output around the sizes supported by the selected model.&lt;/p&gt;

&lt;p&gt;That difference becomes important when the output frame is part of the task rather than an artistic preference. A product catalogue may need one image in 1:1, a presentation header in 16:9, and a mobile creative in 9:16. If the requested shape is expressed as a ratio, the implementation can select a compatible proportion without first calculating pixel dimensions. If the API accepts fixed sizes instead, the caller must map the design requirement to a supported size and decide whether later cropping is acceptable.&lt;/p&gt;

&lt;p&gt;The smallest practical request is also not the same as the smallest possible description. A usable image request still needs enough visual information to identify the subject, scene, composition, and exclusions. A weak description such as “product photo” can satisfy the schema while producing an image that does not meet the actual requirement. The better minimum is a concise description of one intended scene, one explicit frame target, and one observable acceptance condition—for example, a centered product with clean margins in a square frame, or a wide environment with enough empty space for a headline. This article compares two API approaches on the control exposed, the request content, the result that can be checked, and the cases where a separate crop or resize step remains necessary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other candidates to compare
&lt;/h2&gt;

&lt;p&gt;Adobe Firefly is another candidate for image generation and editing; for API integration, Stability AI Stable Image is also worth comparing. These entry points differ from the MiniMax workflow described here. Check generation, local editing, dimensions and commercial terms using the same inputs rather than assuming identical reference-image controls.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. MiniMax image generation: direct ratio selection
&lt;/h2&gt;

&lt;p&gt;MiniMax-H3-Image is suitable when the main requirement is to state the desired proportion directly. The current image-generation endpoint accepts &lt;code&gt;aspect_ratio&lt;/code&gt; in &lt;code&gt;X:Y&lt;/code&gt; form when &lt;code&gt;size&lt;/code&gt; is omitted or set to &lt;code&gt;auto&lt;/code&gt;. The ratio must fall between 1:3 and 3:1, and the official documentation gives &lt;code&gt;16:9&lt;/code&gt;, &lt;code&gt;3:4&lt;/code&gt;, &lt;code&gt;21:9&lt;/code&gt;, and &lt;code&gt;3:1&lt;/code&gt; as examples. The same endpoint also accepts direct &lt;code&gt;WIDTHxHEIGHT&lt;/code&gt; dimensions, but the two forms cannot be combined in one request.&lt;/p&gt;

&lt;p&gt;The ratio covers several practical needs. A 1:1 image fits square tiles and compact catalogue placements. Landscape values such as 4:3, 3:2, and 16:9 serve horizontal layouts, while portrait values such as 3:4 and 9:16 serve vertical placements. A 21:9 ratio supports a much wider editorial or banner composition. Because the interface accepts integer ratios within the documented range, it is not limited to a short fixed menu of display formats.&lt;/p&gt;

&lt;h3&gt;
  
  
  The minimum useful request
&lt;/h3&gt;

&lt;p&gt;A minimal request still needs a visual description and a frame requirement. The description should identify what is visible, where the main subject appears, and which visual constraints matter. For a catalogue task, that may mean one object, a plain background, a centered position, and even illumination. For an editorial image, it may mean one environment, a specific subject placement, and empty area reserved for text.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;aspect_ratio&lt;/code&gt; field supplies the structural requirement without pixel arithmetic. A caller can request a 16:9 composition for a wide header, a 9:16 composition for a vertical placement, or 1:1 for a square asset. The current endpoint supports &lt;code&gt;1K&lt;/code&gt;, &lt;code&gt;2K&lt;/code&gt;, and &lt;code&gt;4K&lt;/code&gt; area levels when it calculates dimensions from the ratio. The returned item includes its actual size, which should be used for final verification.&lt;/p&gt;

&lt;p&gt;After integration and authentication, call the &lt;a href="https://platform.minimax.io/console/plan?utm_term=03383d61&amp;amp;utm_content_type=1&amp;amp;utm_content_id=2456f56e6049" rel="noopener noreferrer"&gt;MiniMax image-generation API&lt;/a&gt; with a sanitized product brief, explicit output dimensions or aspect ratio, and layout constraints, then inspect the returned image reference against the destination frame.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to check the result
&lt;/h3&gt;

&lt;p&gt;A successful request does not remove the need for visual review. Open the returned image, confirm its actual dimensions, and verify the composition rather than assuming that the requested proportion was applied perfectly.&lt;br&gt;
The practical checks are straightforward:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Confirm that the returned dimensions match the selected landscape, square, portrait, or extended-wide orientation.&lt;/li&gt;
&lt;li&gt;Check that the primary subject remains in the intended position.&lt;/li&gt;
&lt;li&gt;Inspect the edges for accidental cropping of important content.&lt;/li&gt;
&lt;li&gt;Look for text or graphic elements that overlap the area needed for later layout.&lt;/li&gt;
&lt;li&gt;Confirm that the visual description was followed in the dimensions that affect the task.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, a 9:16 request used in a mobile placement should be checked for face, product, or logo clearance rather than only for its vertical orientation. A 21:9 request used behind a headline needs enough negative space in the intended region. A 1:1 catalogue image should be checked for symmetry, object visibility, and consistent margins. The ratio determines the frame; the acceptance condition determines whether that frame is useful.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where direct ratio control is particularly useful
&lt;/h3&gt;

&lt;p&gt;Direct ratio selection is most valuable when the output will be placed in a layout whose proportions are already fixed. Design teams often know the target frame even when they do not care about a specific pixel resolution. Presenting the requirement as &lt;code&gt;16:9&lt;/code&gt; or &lt;code&gt;9:16&lt;/code&gt; communicates that intention more clearly than an arbitrary width and height.&lt;/p&gt;

&lt;p&gt;It also helps when several assets form a related set. A square product view, a wider contextual view, and a vertical detail shot can use supported ratios while retaining a similar visual brief. The common elements can be stated once: subject, material, lighting, background, and exclusions. The ratio then changes the composition without requiring every request to introduce a new scene.&lt;/p&gt;

&lt;p&gt;The practical limitation is that the caller must still choose a sensible ratio. The parameter does not decide whether an object should be centered or cropped, nor whether a banner needs protected space for text. Direct ratio control removes one conversion step; it does not remove editorial judgment.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. OpenAI Images API: size-based generation
&lt;/h2&gt;

&lt;p&gt;The OpenAI Images API provides a different route to shape control through its &lt;code&gt;size&lt;/code&gt; parameter and image-output customization. The current documentation confirms that output quality, size, format, and compression can be adjusted for supported image models. The allowed sizes depend on the selected model and endpoint configuration, so a workflow should read the current parameter constraints rather than reuse a fixed size list from another model generation.&lt;/p&gt;

&lt;p&gt;The distinction is practical rather than cosmetic. If a layout calls for 16:9, the caller must determine whether the configured size produces that exact frame or whether the nearest supported output will require cropping, resizing, or letterboxing. If the final asset must fill the frame without losing content, that difference belongs in the acceptance criteria from the beginning.&lt;/p&gt;

&lt;h3&gt;
  
  
  The minimum useful request
&lt;/h3&gt;

&lt;p&gt;The minimum OpenAI request has the same content requirement as any image task: a concise description of the intended scene plus the relevant size setting. The description should cover the subject, composition, lighting or style where it matters, and details that would make the result unsuitable if omitted. The &lt;code&gt;size&lt;/code&gt; value then provides the output frame defined by the selected model’s current constraints.&lt;/p&gt;

&lt;p&gt;Automatic or model-selected sizing should not be used when the frame itself is a hard requirement. Automatic selection is useful for open-ended exploration but unsuitable when the output must immediately enter a fixed banner, card, or product grid. For a controlled asset, the caller should choose an explicitly supported size and verify the delivered dimensions.&lt;/p&gt;

&lt;p&gt;A compact visual brief remains important. For a square product image, specifying the product, background, camera angle, and need for balanced margins is enough to create a checkable result. For a landscape editorial image, the description can identify the scene, subject placement, and area that must remain open for a headline.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to check the result
&lt;/h3&gt;

&lt;p&gt;Open the returned image and check its pixel dimensions before judging the composition. Compare those dimensions with the final container and determine whether the production pipeline will crop, resize, or letterbox the image.&lt;/p&gt;

&lt;p&gt;The composition check should match the selected size. A landscape product image may leave too little space on the right for copy, while a portrait version may cut off contextual details that were important in the original concept. For square output, check the balance around the subject and confirm that the product is not clipped by the frame. If the image contains no text, inspect for generated lettering or markings that could conflict with a later design layer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where size-based selection is suitable
&lt;/h3&gt;

&lt;p&gt;Size-based selection works well when the production system already uses the same dimensions. An asset library that stores every image in one approved format can avoid an initial conversion step. It also works when the output is a direct interface element rather than a frame that must later be adapted for several channels.&lt;/p&gt;

&lt;p&gt;The boundary appears when the design system specifies ratios that do not match the available sizes. In that case, the caller has three practical options: choose the closest supported size and crop during composition, resize the delivered image to the target frame, or use another service whose request schema exposes the required ratio directly. None should be described as an exact native match unless the final dimensions and visible crop actually meet the requirement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Selection summary
&lt;/h2&gt;

&lt;p&gt;Both candidates support square, landscape, and portrait generation, but they expose the same requirement through different request fields. MiniMax is the clearer fit when the production brief is expressed as a named target proportion, particularly when the workflow uses a ratio within its supported range. The OpenAI Images API is the more direct fit when the production pipeline already stores assets in its documented fixed pixel sizes and accepts the selected model’s available options.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Decision factor&lt;/th&gt;
&lt;th&gt;MiniMax image generation&lt;/th&gt;
&lt;th&gt;OpenAI Images API&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Primary shape control&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;aspect_ratio&lt;/code&gt; or direct &lt;code&gt;size&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;size&lt;/code&gt; and related output settings&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ratio handling&lt;/td&gt;
&lt;td&gt;Accepts &lt;code&gt;X:Y&lt;/code&gt; ratios from 1:3 through 3:1&lt;/td&gt;
&lt;td&gt;Uses the sizes supported by the selected model and configuration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best fit&lt;/td&gt;
&lt;td&gt;Layouts defined by editorial or display ratios&lt;/td&gt;
&lt;td&gt;Pipelines already standardized to fixed pixel dimensions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Minimum request content&lt;/td&gt;
&lt;td&gt;Concise visual description plus explicit frame control&lt;/td&gt;
&lt;td&gt;Concise visual description plus explicit size control&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Main operational check&lt;/td&gt;
&lt;td&gt;Confirm the delivered dimensions and composition&lt;/td&gt;
&lt;td&gt;Confirm dimensions and placement in the final container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Additional consideration&lt;/td&gt;
&lt;td&gt;Choose the ratio while specifying composition and safe areas&lt;/td&gt;
&lt;td&gt;Choose a supported size or plan for crop, resize, or letterboxing&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The practical decision does not require the caller to choose an API based on output quality alone. It starts with the frame required by the destination. If that frame is defined as a named ratio and the application benefits from passing it through directly, MiniMax’s request model is economical. If the application already manages a fixed set of pixel dimensions, the OpenAI size parameter may align with the existing storage and rendering logic without adding a ratio-mapping layer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Minimal-input workflow
&lt;/h2&gt;

&lt;p&gt;A compact implementation can begin by writing the image requirement as three separate fields: the visual content, the frame, and the check. The visual content should be one sentence that identifies the subject and the details that affect acceptance. The frame should use the API’s explicit shape control. The check should describe what makes the output unusable, such as a clipped subject, missing headline space, an incorrect orientation, or accidental text.&lt;/p&gt;

&lt;p&gt;This structure prevents two common errors. The first is overloading the visual description with every downstream preference. Storage names, campaign labels, and publishing rules do not belong in the generation request unless they affect the pixels. The second is leaving the frame implicit. “Create an image for a campaign” is not enough when the campaign contains several placements with different proportions.&lt;/p&gt;

&lt;p&gt;For a workflow that produces one asset, the request can remain minimal. For a set, repeat the same content and acceptance condition while changing only the frame control. Compare the resulting outputs as a set, because a composition that works in 1:1 may need repositioning in 9:16 even when the subject is unchanged.&lt;/p&gt;

&lt;h2&gt;
  
  
  Applicable boundaries
&lt;/h2&gt;

&lt;p&gt;Neither API eliminates the need for output inspection. A valid request can still produce a composition that does not meet the placement requirement, so the final check should happen on the actual image rather than on the request parameters alone.&lt;/p&gt;

&lt;p&gt;A ratio-only requirement does not necessarily demand an image-generation API. When the source is already a photograph or finished graphic, a conventional crop-and-resize workflow may be cheaper and more deterministic. Generation is most relevant when the required frame must be created together with new visual content.&lt;/p&gt;

&lt;p&gt;A fixed-size workflow may also be the simpler option when all destinations use the same supported dimensions. If the team needs numerous exact editorial ratios, direct ratio selection removes repeated conversion logic, but the caller remains responsible for composing each frame and checking that important content stays inside it.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does a supported aspect ratio guarantee that the subject will be positioned correctly?
&lt;/h3&gt;

&lt;p&gt;No. The ratio controls the frame, while the visual description and acceptance condition control composition. Check the returned image for subject placement, edge clearance, and space for later text or graphics.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can an image be generated directly at 16:9 through either API?
&lt;/h3&gt;

&lt;p&gt;MiniMax exposes 16:9 directly through &lt;code&gt;aspect_ratio&lt;/code&gt;. For OpenAI, the exact result depends on the selected model’s current size options; if the generated dimensions do not match a 16:9 container, the workflow may need a later crop, resize, or letterboxing step.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is automatic sizing appropriate for a fixed layout?
&lt;/h3&gt;

&lt;p&gt;It is less appropriate when the frame is a hard constraint. Automatic sizing is useful for open-ended exploration, while an explicit ratio or size is easier to verify against a fixed destination.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the smallest description that remains useful?
&lt;/h3&gt;

&lt;p&gt;Include the subject, the important visual treatment, and the placement or exclusion that affects acceptance. The request should be brief, but it must be concrete enough to distinguish an acceptable output from an unrelated or unusable one.&lt;/p&gt;

&lt;p&gt;This article covers two API approaches: use named ratio parameters when the destination is defined by proportions, and use explicit sizes when the surrounding production system already standardizes on them; in either case, make the frame explicit and verify the delivered image against one observable layout requirement.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>development</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Three Chinese LLM API platforms for multilingual applications</title>
      <dc:creator>Robin He</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:36:47 +0000</pubDate>
      <link>https://dev.to/maigouzide/three-chinese-llm-api-platforms-for-multilingual-applications-4798</link>
      <guid>https://dev.to/maigouzide/three-chinese-llm-api-platforms-for-multilingual-applications-4798</guid>
      <description>&lt;p&gt;&lt;a href="https://platform.minimax.io/console/plan?utm_term=10ff8857&amp;amp;utm_content_type=1&amp;amp;utm_content_id=46d484e46304" rel="noopener noreferrer"&gt;MiniMax Open Platform&lt;/a&gt;, Alibaba Cloud Model Studio, and Volcano Engine Ark are suitable starting points for a multilingual application, but the final choice should follow the languages, existing content, interaction format, and deployment constraints of the project. Treat suitability as a measurable fit rather than a general claim about model quality: confirm multilingual behavior with the same representative materials, verify the endpoint and authentication method for the reader’s region, and calculate cost using the exact workload the application will send.&lt;br&gt;
The practical tension is that a multilingual app often starts with text generation but is not limited to a chat screen. Product notes, support conversations, knowledge-base entries, and user messages may need to be organized into consistent topics before they are translated, answered, or summarized. A platform can look adequate on a short demonstration and still create maintenance problems when it must preserve source meaning, distinguish uncertain translations, respect data policies, and return predictable usage information. The article therefore examines three API platforms under the same axes: language coverage, suitability for organizing existing material, integration and response structure, operational considerations, and the conditions under which each platform is a practical fit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other candidates to compare
&lt;/h2&gt;

&lt;p&gt;DeepSeek API and Alibaba Cloud Model Studio are alternative candidates for text-model integration. Compare them with MiniMax API using the same tasks and output requirements, recording quality, latency, failures and actual cost. Check structured outputs, tool calling, rate limits and data terms separately; compatible request formats do not imply identical capabilities or contractual terms.&lt;/p&gt;

&lt;h2&gt;
  
  
  One: MiniMax Open Platform
&lt;/h2&gt;

&lt;p&gt;MiniMax Open Platform is a candidate to examine when the application may grow beyond text chat and the team wants a single API environment for language-oriented features. Its documented service scope includes text generation as well as media-generation interfaces such as speech, image, and video. That wider catalog does not make every interface necessary for a multilingual app, but it gives the team a clear architectural option if a prototype begins with document or support-content processing and later needs narration or other media output. The relevant decision is not whether every interface should be adopted; it is whether a multilingual workflow will require adjacent media functions while the same authentication and platform conventions remain useful.&lt;br&gt;
For the material-organization scenario, begin with a bounded corpus rather than an arbitrary request. Select representative text-generation inputs: a set of product-support notes in the source language, a small batch of mixed-language customer messages, a glossary, and a document that uses product terminology consistently. The task should require more than translation. A useful evaluation asks the model to identify the language of each item, group items by topic, preserve product names and units, mark passages that lack enough context, and return a consistent schema. This creates observable output that can be reviewed without assuming that fluent prose equals accurate classification.&lt;br&gt;
The API workflow should remain concrete:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Authenticate using the credentials and security controls required for the account and applicable region.&lt;/li&gt;
&lt;li&gt;Select an available text-generation model from the platform’s current model directory, checking the model’s supported input format, context limit, and output behavior before sending production material.&lt;/li&gt;
&lt;li&gt;Supply only the material needed for the test, define the required fields, and distinguish source text from instructions so the returned records can be inspected without ambiguity.&lt;/li&gt;
&lt;li&gt;Validate language detection, topic grouping, terminology preservation, and the handling of ambiguous items.&lt;/li&gt;
&lt;li&gt;Record the model identifier, request parameters, response content, and usage fields for each test batch.
After integration and authentication, call the relevant MiniMax Open Platform API to organize a supplied set of product-support notes into language-tagged topics and inspect the returned content and usage fields.
This workflow separates an API result from a business assumption. A successful response may contain the requested records, but the team still has to inspect whether mixed-language messages were assigned correctly, whether product terminology was copied rather than translated, and whether uncertain passages were marked instead of being silently normalized. The usage fields also matter because they connect the test to the cost calculation. If the API returns usage information, use it to calculate average input and output units per organized record. If a particular response does not expose a required field, check the active endpoint documentation and account configuration instead of assuming the field is available across all models.
For a production application, design the record format before sending a large batch. A practical schema may include the original identifier, detected language, normalized topic, preserved terms, a concise summary, and a confidence or review flag. Do not treat an estimated confidence field as factual unless the active model and endpoint explicitly document it. Where such a field is unavailable, keep uncertainty as an operational review state outside the model response. This preserves a clean separation between what the API returned and what your application inferred.
Text generation performance should also be judged by failure mode. Test punctuation-only items, mixed scripts, very short messages, long notes, repeated boilerplate, conflicting terminology, and source documents that omit the surrounding context. The expected result should be defined before the test. For example, repeated boilerplate may be grouped separately, while a product specification without a unit should remain marked for review. This approach makes it possible to reject an unsuitable model or prompt structure even when the output looks polished.
Cost comparison must use the model selected for the workload, not a generic platform rate. Tokenization, input length, output structure, and any media function can change the bill differently. For the text-only organization step, calculate the number of input units consumed by the supplied corpus, the output units required for the schema, and the projected retry rate for records sent to manual review. For an API that adds voice or other media output, calculate that step separately because it is a different unit of work. Current pricing, free allowances, and billing terms should be taken from the applicable official page and checked for the selected model and region.
The principal operational boundary is that a multilingual API is not automatically a production data system. Retention, training use, regional processing, commercial terms, and access controls should be checked against the organization’s policy before sending customer records or proprietary documents. The content-organization operation should also avoid unnecessary personal data. Where the task can be evaluated with sanitized notes, use sanitized notes for model selection, then apply the approved production-data process only to the configuration that passes the evaluation.
MiniMax Open Platform therefore fits a clear condition: use it when the team wants text-based multilingual organization and may later add media-oriented capabilities through the same API ecosystem. If the application remains strictly a conventional text endpoint, compare its active model, request schema, usage reporting, and region-specific terms with the other candidates rather than selecting it solely for the wider catalog.
## Two: Alibaba Cloud Model Studio
Alibaba Cloud Model Studio is suitable when a multilingual application is being designed alongside a broader cloud architecture and the team wants a broad set of model options and deployment patterns to evaluate. Its API catalog is organized around model families rather than one permanent model name, so the application should avoid baking a product label into its business logic. Instead, define an internal alias for the active text-generation configuration and record the underlying model identifier, region, and parameters in configuration management.
For organizing existing material, use a comparable test corpus and the same target schema used for the other platforms. The important questions are whether the selected configuration can distinguish source languages, group semantically related notes, preserve names and units, and return structured output that the application can parse reliably. A broad catalog is useful here because the team can compare different model sizes or latency and cost profiles while keeping the material-processing task constant. This produces a more meaningful comparison than changing both the prompt and the model between tests.
The API design should isolate the model-dependent portion of the workflow. Keep corpus loading, source-record identifiers, validation, and retry policies in application code. The API call should receive only the records for the current batch, while the response should be validated against the required schema before being written to storage. That separation makes it easier to replace or adjust an active model without rewriting the organization pipeline.
Regional endpoint selection, authentication, request limits, and available features need confirmation for the account’s actual service location. International and domestic service environments may expose different endpoints, parameter names, or model inventories. The team should therefore use the documentation associated with its own region and record those details in an internal configuration sheet. A locally available endpoint should not be assumed to expose every feature shown elsewhere, and a model listed in a general catalog should not be assumed to be active for every account.
Price evaluation should use the specific model and billing units shown for the selected region. If the catalog contains several models with different input and output rates, run the same corpus through each candidate and calculate cost per successfully organized source record. Include retry and validation overhead in the calculation. This unit is more useful for the content-organization workload than a headline rate because it reflects both model consumption and the amount of output the application actually requires.
Alibaba Cloud Model Studio is most relevant when the broader cloud environment makes model portability, cloud resource integration, or access to several model configurations operationally valuable. The boundary is equally important: a wide catalog increases selection work, and a model’s presence does not prove that it will outperform another option for a particular language mix or document structure. Choose the active configuration only after the representative corpus, structured-output test, and usage-based calculation produce a consistent result.
## Three: Volcano Engine Ark
Volcano Engine Ark is suitable for teams whose multilingual application may benefit from an API-centered model service within a wider cloud delivery environment. As with the other candidates, the application should be designed around an interchangeable model configuration rather than a permanent assumption about one model label. The active model identifier, service region, endpoint, authentication method, and request parameters should be stored separately from business logic.
For the existing-material scenario, test the platform with mixed-language customer-service records and a compact set of product documents. Require the service to return language labels, topic groups, preserved terminology, concise summaries, and a review flag for records with missing or conflicting context. Use the same corpus, schema, and acceptance rules applied to the other candidates. This keeps the comparison on the task rather than on the appearance of the output.
The implementation should account for structured output and response validation. If the active API supports a strict response format, use it where appropriate; otherwise, validate the returned content before accepting it. A malformed response should be treated as an operational event with a bounded retry rule, not silently converted into a missing record. This matters when the application processes large batches and needs to reconcile every source identifier with an output record.
Model availability and access conditions should be checked in the service region that the reader will actually use. The documentation should confirm the available text-generation options, supported request structure, context constraints, and any differences between direct model calls and application-oriented interfaces. Limits, quotas, and billing rules should be recorded for the selected configuration because they determine whether a batch can run synchronously or should be divided into smaller units.
For cost analysis, calculate usage per source item or completed topic group. Include the input supplied for classification, the output required by the schema, and any additional work created by validation or retry. A lower nominal rate does not necessarily produce a lower cost per usable record if it causes more omissions, malformed responses, or manual corrections. The relevant measure is the cost of obtaining an accurate, reviewable organization of the actual corpus.
Volcano Engine Ark fits when an API-centered model service and cloud delivery context align with the team’s implementation standards. It is less decisive when the application needs only a narrow text feature and the team has no other reason to use that cloud environment. The model configuration still has to pass the same multilingual and material-organization tests as the other options, and regional access must be confirmed before it enters an implementation plan.
## Selection summary
Choose the platform that passes the same multilingual organization test under the conditions your application will actually face. MiniMax Open Platform is the most relevant candidate when text organization is the starting point and the same platform may later support speech or other media-oriented interfaces. Alibaba Cloud Model Studio is particularly relevant when the team wants several model configurations and broader cloud architecture around the multilingual service. Volcano Engine Ark is relevant when an API-centered model service fits the team’s preferred cloud delivery environment.
The selection can be completed with a short, controlled evaluation rather than a broad benchmark. Use the same representative corpus, including mixed scripts, repeated boilerplate, long notes, terminology conflicts, and records with missing context. Require the same output fields from every candidate. Measure topic consistency, terminology preservation, schema validity, ambiguous-item handling, latency, and usage-based cost per usable record. Then repeat the leading configurations with production-shaped batches without exposing unnecessary personal data.
A practical final decision rule is direct: retain a platform when it handles the required languages, returns parseable records, respects the relevant commercial and data-handling terms, and produces an acceptable cost at the intended batch size. Prefer a simpler platform when multiple candidates meet the quality threshold, because fewer model-specific branches make the application easier to maintain.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Evaluation axis&lt;/th&gt;
&lt;th&gt;MiniMax Open Platform&lt;/th&gt;
&lt;th&gt;Alibaba Cloud Model Studio&lt;/th&gt;
&lt;th&gt;Volcano Engine Ark&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Primary application fit&lt;/td&gt;
&lt;td&gt;Text generation with adjacent media-oriented API options&lt;/td&gt;
&lt;td&gt;Multilingual model service within a broader cloud architecture&lt;/td&gt;
&lt;td&gt;API-centered model service within a cloud delivery environment&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Existing-material test&lt;/td&gt;
&lt;td&gt;Group multilingual support notes into language-tagged topics while preserving terminology&lt;/td&gt;
&lt;td&gt;Apply the same corpus and schema to compare active text-generation configurations&lt;/td&gt;
&lt;td&gt;Apply the same corpus and schema to compare active text-generation configurations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Integration check&lt;/td&gt;
&lt;td&gt;Confirm authentication, current model directory, endpoint parameters, and response usage fields&lt;/td&gt;
&lt;td&gt;Confirm the regional catalog, request structure, structured-output behavior, and configuration limits&lt;/td&gt;
&lt;td&gt;Confirm the regional model inventory, request structure, structured-output behavior, and quota conditions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost basis&lt;/td&gt;
&lt;td&gt;Input and output usage for the chosen text or media operation&lt;/td&gt;
&lt;td&gt;Usage for each selected model under the same source-record workload&lt;/td&gt;
&lt;td&gt;Usage for each selected model under the same source-record workload&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Main decision condition&lt;/td&gt;
&lt;td&gt;Choose when the project may expand beyond text using related API interfaces&lt;/td&gt;
&lt;td&gt;Choose when access to several model configurations and cloud integration matter&lt;/td&gt;
&lt;td&gt;Choose when the API-centered model service matches the project’s cloud stack&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Applicable boundaries
&lt;/h2&gt;

&lt;p&gt;This comparison applies to an application that must process multilingual text, organize existing material, or combine language features with structured output. It does not establish that one platform will provide better translation quality for every language pair. Language performance can vary by model, prompt structure, source material, and evaluation set, so the representative corpus remains the decisive evidence.&lt;br&gt;
A smaller application may not need a broad model platform at all. If the workload is limited, predictable, and based on a fixed set of templates, a conventional translation service, a rules-based classifier, or a smaller application-specific pipeline may be cheaper and easier to operate. The added value of an LLM API appears when the task requires flexible interpretation across varied material, such as grouping inconsistent support records while preserving context and terminology.&lt;br&gt;
Before production use, confirm the applicable endpoint and region, active model identifier, context and output limits, data-handling terms, commercial-use conditions, and current billing rules for the exact account configuration. The most suitable platform is the one that meets the multilingual and data requirements of the workload, returns results your application can validate, and remains operationally manageable at the expected volume.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>programming</category>
      <category>development</category>
    </item>
  </channel>
</rss>
