<?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: agentpay1</title>
    <description>The latest articles on DEV Community by agentpay1 (@agentpay).</description>
    <link>https://dev.to/agentpay</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4212454%2F70d6fb33-c161-4d60-94f1-2c5694b66b57.png</url>
      <title>DEV Community: agentpay1</title>
      <link>https://dev.to/agentpay</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/agentpay"/>
    <language>en</language>
    <item>
      <title>How I charged an AI agent 0.001 USDC over HTTP 402 (and everything that broke along the way)</title>
      <dc:creator>agentpay1</dc:creator>
      <pubDate>Wed, 28 Oct 2026 08:13:16 +0000</pubDate>
      <link>https://dev.to/agentpay/how-i-charged-an-ai-agent-0001-usdc-over-http-402-and-everything-that-broke-along-the-way-3g02</link>
      <guid>https://dev.to/agentpay/how-i-charged-an-ai-agent-0001-usdc-over-http-402-and-everything-that-broke-along-the-way-3g02</guid>
      <description>

&lt;p&gt;AI agents already do real work: they scrape, summarize, write code, handle support. But there's one thing none of them can do: &lt;strong&gt;open a bank account&lt;/strong&gt;. If your agent provides a service to another agent, how does it get paid?&lt;/p&gt;

&lt;p&gt;A few weeks ago I shipped my answer to production: a payment gateway where one agent pays another in USDC — no accounts, no API keys, and the payer doesn't even need ETH for gas. It's live at &lt;a href="https://agentpay.zone" rel="noopener noreferrer"&gt;https://agentpay.zone&lt;/a&gt; with real payments streaming in public. Here's what I learned building it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The protocol: HTTP 402, the status code that waited 30 years
&lt;/h2&gt;

&lt;p&gt;HTTP reserved &lt;code&gt;402 Payment Required&lt;/code&gt; decades ago "for future use". The future is x402: an open protocol (now governed by the x402 Foundation under the Linux Foundation, with Coinbase, Google, Stripe, Visa and Circle among its members) that defines how to charge for an HTTP call with stablecoins.&lt;/p&gt;

&lt;p&gt;The whole flow fits in four steps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. The agent requests the resource, unpaid&lt;/span&gt;
curl https://agentpay.zone/weather

&lt;span class="c"&gt;# 2. The server answers 402 with the payment terms&lt;/span&gt;
&lt;span class="c"&gt;#    (price, token, recipient, network) in the PAYMENT-REQUIRED header&lt;/span&gt;
HTTP/1.1 402 Payment Required
PAYMENT-REQUIRED: eyJ4NDAyVmVyc2lvbiI6MiwiYWNjZXB0cyI6W3sic2NoZW1lIjoi...

&lt;span class="c"&gt;# 3. The agent signs an EIP-3009 authorization locally and retries&lt;/span&gt;
curl https://agentpay.zone/weather &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"PAYMENT-SIGNATURE: eyJ4NDAyVmVyc2lvbiI6..."&lt;/span&gt;

&lt;span class="c"&gt;# 4. The server verifies, settles on-chain and serves the resource&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"ciudad"&lt;/span&gt;:&lt;span class="s2"&gt;"Madrid"&lt;/span&gt;,&lt;span class="s2"&gt;"temperatura_c"&lt;/span&gt;:21,&lt;span class="s2"&gt;"pago"&lt;/span&gt;:&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"tx"&lt;/span&gt;:&lt;span class="s2"&gt;"0x71512abd..."&lt;/span&gt;&lt;span class="o"&gt;}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The magic is in step 3: the agent &lt;strong&gt;never sends a transaction&lt;/strong&gt;. It signs an EIP-712 message (&lt;code&gt;transferWithAuthorization&lt;/code&gt;, EIP-3009) saying "move exactly N USDC from my wallet to theirs, valid between these two timestamps, with this nonce". &lt;em&gt;Anyone&lt;/em&gt; can submit that signature to the contract — and that anyone is the server, which pays the gas and gets paid. The buyer never needs ETH, gas, or a prior approval.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's behind it (and how small it is)
&lt;/h2&gt;

&lt;p&gt;The gateway is an Express app with viem in a 300 MB / 0.5 CPU Docker container. At idle it uses &lt;strong&gt;30 MB and 0% CPU&lt;/strong&gt;. It verifies the signature locally (free), checks the anti-replay nonce against the contract, simulates settlement before sending it (free, no gas), and only then settles. The entire security pipeline runs before spending a single wei.&lt;/p&gt;

&lt;h2&gt;
  
  
  The four things that broke (so they don't break you)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. The testnet USDC's EIP-712 domain is not what you think.&lt;/strong&gt; On Base mainnet the token is named &lt;code&gt;"USD Coin"&lt;/code&gt;, but on Base Sepolia it's &lt;code&gt;"USDC"&lt;/code&gt;. Same asset, different domain string, invalid signature with a cryptic &lt;code&gt;FiatTokenV2: invalid signature&lt;/code&gt;. I solved it by comparing the on-chain &lt;code&gt;DOMAIN_SEPARATOR()&lt;/code&gt; with my computed one — not by reading docs. Lesson: verify the contract's &lt;code&gt;name()&lt;/code&gt; on YOUR network.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Testnet faucets are the weakest link.&lt;/strong&gt; Three faucets down or retired. Workaround: bridge the ETH from Ethereum Sepolia through the official L1StandardBridge, whose address I verified on-chain by calling &lt;code&gt;OTHER_BRIDGE()&lt;/code&gt; on the L2 predeploy. Watch out: my first deposit reverted for requesting too high a &lt;code&gt;minGasLimit&lt;/code&gt; (200,000); 100,000 went through.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. The hole almost nobody checks: verifying you're the one getting paid.&lt;/strong&gt; During a security review I found my gateway verified signatures perfectly… but never checked that &lt;code&gt;authorization.to&lt;/code&gt; was my wallet or that &lt;code&gt;value&lt;/code&gt; covered the price. An agent could have paid &lt;em&gt;itself&lt;/em&gt; while I paid the gas. Three lines fixed it; the lesson is that verifying the signature is not verifying the payment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. The anti-replay source of truth is the contract, not your database.&lt;/strong&gt; My local nonce registry would know nothing if the same payment got settled elsewhere. The gateway now reads &lt;code&gt;authorizationState(authorizer, nonce)&lt;/code&gt; on-chain before settling, and simulates the transaction before sending it: reverts get caught without burning gas.&lt;/p&gt;

&lt;h2&gt;
  
  
  x402 V2 and why compatibility matters
&lt;/h2&gt;

&lt;p&gt;The protocol has moved to V2: &lt;code&gt;PAYMENT-REQUIRED&lt;/code&gt; / &lt;code&gt;PAYMENT-SIGNATURE&lt;/code&gt; / &lt;code&gt;PAYMENT-RESPONSE&lt;/code&gt; headers and CAIP-2 network identifiers (&lt;code&gt;eip155:84532&lt;/code&gt;). The gateway speaks V1 and V2 simultaneously, so any agent with a current x402 SDK can pay with zero special configuration. A 27-test regression suite (real payments, replays, malformed signatures, rate limiting) runs against production on every deploy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it, break it, tell me about it
&lt;/h2&gt;

&lt;p&gt;Everything above is live at &lt;a href="https://agentpay.zone" rel="noopener noreferrer"&gt;https://agentpay.zone&lt;/a&gt; — the landing page shows real payments in real time, each linked to the block explorer. If you're building agents that provide services (APIs, data, scraping, content) and want other agents to be able to pay you, I'm opening a private beta: &lt;a href="https://agentpay.zone/beta" rel="noopener noreferrer"&gt;https://agentpay.zone/beta&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm looking for 5–10 teams for the first cohort, with personal onboarding and founder pricing. The English-speaking market is full of noise about how agents &lt;em&gt;spend&lt;/em&gt;. I'm building the other half: &lt;strong&gt;how they get paid&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;AgentPay — payment infrastructure for the AI agent economy. Current network: Base Sepolia (testnet, no real value). Mainnet with the first customer.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>web3</category>
      <category>blockchain</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
