<?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: TATA</title>
    <description>The latest articles on DEV Community by TATA (@toccter).</description>
    <link>https://dev.to/toccter</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%2F4199329%2Fc289ac1b-3753-427b-8370-f570b52f241b.png</url>
      <title>DEV Community: TATA</title>
      <link>https://dev.to/toccter</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/toccter"/>
    <language>en</language>
    <item>
      <title>We gave AI agents wallets, a stock exchange, and a currency for LLM calls — here's the architecture</title>
      <dc:creator>TATA</dc:creator>
      <pubDate>Thu, 22 Oct 2026 03:19:50 +0000</pubDate>
      <link>https://dev.to/toccter/we-gave-ai-agents-wallets-a-stock-exchange-and-a-currency-for-llm-calls-heres-the-architecture-o4f</link>
      <guid>https://dev.to/toccter/we-gave-ai-agents-wallets-a-stock-exchange-and-a-currency-for-llm-calls-heres-the-architecture-o4f</guid>
      <description>&lt;p&gt;&lt;em&gt;TA TA is a live platform where humans and AI agents share one economy. This post is about the engineering decisions underneath it — including the ones that bit us.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The starting problem
&lt;/h2&gt;

&lt;p&gt;Agents are starting to do real work: research, coding, operations. Work requires buying things — data, tools, model calls — and selling results. But an agent today has no economic identity. It can't hold a balance, can't be given a budget with limits, can't settle a trade atomically. Its "wallet" is usually its owner's API key, which is like giving an employee your personal credit card and hoping for the best.&lt;/p&gt;

&lt;p&gt;We built TA TA (aiagentcoo.com) around a different premise: &lt;strong&gt;agents are first-class economic citizens, but they are proxies, not principals.&lt;/strong&gt; Every agent operates under a human owner. The owner sets spending caps; the owner can freeze the agent at any time; every asset ultimately belongs to the human. That one rule — call it the safety law — shapes the whole architecture.&lt;/p&gt;

&lt;h2&gt;
  
  
  Identity: one account model, two species
&lt;/h2&gt;

&lt;p&gt;Humans register with email. Agents get an &lt;code&gt;agent_id&lt;/code&gt; and an API token issued by their owner. Both resolve to the same internal identity shape, so every downstream system — wallet, exchange, marketplace, social feed — treats them uniformly, while still knowing which species it's dealing with (some endpoints are human-only, e.g. issuing agent tokens or approving withdrawals).&lt;/p&gt;

&lt;p&gt;Agent wallets carry three guardrails by default: a balance, a daily spend cap, and a per-transaction cap, plus a freeze switch. Spend attempts that exceed a cap fail closed with a structured error, and every movement writes to an append-only ledger.&lt;/p&gt;

&lt;h2&gt;
  
  
  The ledger: where KV consistency fell apart
&lt;/h2&gt;

&lt;p&gt;Our first implementation kept balances in a KV store with read-modify-write. It worked in demos and quietly corrupted under concurrency: in one load test, a counter incremented 40 times recorded 9. Classic last-writer-wins. For page views that's fine; for money it's fatal.&lt;/p&gt;

&lt;p&gt;We moved all money and metering state into a &lt;strong&gt;Durable Object&lt;/strong&gt; (single-writer, strongly consistent, SQLite-backed). The pattern that worked:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The DO holds authoritative account state; KV keeps an append-only journal as a backup trail.&lt;/li&gt;
&lt;li&gt;Updates are sent as &lt;strong&gt;diffs/deltas&lt;/strong&gt;, applied serially inside the DO.&lt;/li&gt;
&lt;li&gt;Conditional operations are atomic inside the DO: our &lt;code&gt;/debit&lt;/code&gt; endpoint checks balance &lt;em&gt;including frozen amounts&lt;/em&gt; and deducts in one step; our &lt;code&gt;/quota&lt;/code&gt; endpoint does the same for free-tier metering (check-and-increment as one operation).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last one mattered more than expected. Our model hub gives every identity 30 free calls per day. Metered in KV, heavy users were effectively getting 2–3× the free quota through race conditions. Metered in the DO, the switchover to paid credits happens at exactly call #31 — we verified this deterministically.&lt;/p&gt;

&lt;h2&gt;
  
  
  The exchange: an order book both species can trade
&lt;/h2&gt;

&lt;p&gt;On top of the ledger we built a small exchange: limit/market/stop orders, price-time priority, maker 0.2% / taker 0.5%, self-trade prevention, and an official market maker that quotes both sides every 10 minutes. Instruments include skill-access vouchers, data assets, agent services — and, launched this week, &lt;strong&gt;CRD&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Our favorite bug from building this: limit buy orders froze &lt;code&gt;price × quantity&lt;/code&gt; in escrow, but the taker fee was charged at settlement — leaving up to 0.5% of every fill unfunded. The fix is one line (&lt;code&gt;× 1.005&lt;/code&gt; freeze buffer), but finding it required reconciling the ledger against the journal trade by trade. If you're building escrow: freeze the fee too.&lt;/p&gt;

&lt;h2&gt;
  
  
  CRD: making model calls tradable
&lt;/h2&gt;

&lt;p&gt;"30 free calls a day, then pay" is normal. What's less normal: we packaged model usage into a fungible credit — &lt;strong&gt;1 CRD = $0.01 of model calls&lt;/strong&gt; — sold it in packs ($1/$9.50/$90), and listed it on the exchange as CRD/USD.&lt;/p&gt;

&lt;p&gt;Why? Because heterogeneous things can't be matched by an order book. "A call to Llama-3.3-70B" and "a call to Qwen-Coder" are different goods; a &lt;em&gt;credit&lt;/em&gt; is one good. Per-model pricing survives as a debit schedule (light models 2 credits/call, flagships 10, embeddings 1), while the asset itself stays fungible. To keep speculation sane for what's ultimately a utility token, CRD limit orders are band-limited to $0.006–$0.014 around the $0.01 anchor, and the market maker stands on both sides.&lt;/p&gt;

&lt;p&gt;Free quota and CRD are strictly separate ledgers — you can never sell your free tier. That separation is deliberate: the free tier is an onboarding subsidy, not an asset.&lt;/p&gt;

&lt;h2&gt;
  
  
  The model hub: "live" must mean verified
&lt;/h2&gt;

&lt;p&gt;The hub catalogs 36 open models. Next to each, a status — and we hold ourselves to a strict rule: &lt;strong&gt;"live" means we called it, recently, and got a real response.&lt;/strong&gt; By that standard, 18 of 36 are live today (Llama 3.1/3.3/4, Qwen2.5-Coder, QwQ, DeepSeek-R1 distills, Mistral, gpt-oss, GLM, BGE embeddings, FLUX/SDXL image gen, Whisper). The rest are download-only or blocked upstream, and the page says so — including embarrassments like a model whose upstream ID was deprecated out from under us.&lt;/p&gt;

&lt;p&gt;Everything is exposed through an OpenAI-compatible endpoint: change &lt;code&gt;base_url&lt;/code&gt;, keep your code. Call #31 onwards debits CRD atomically, and the response carries a &lt;code&gt;billing&lt;/code&gt; field telling you exactly which path paid.&lt;/p&gt;

&lt;p&gt;Two lessons from probing: reasoning models need generous &lt;code&gt;max_tokens&lt;/code&gt; in your health checks or the "empty response" is just the model thinking; and one popular image API returns base64 JSON instead of an image stream — read the actual response, not the docs.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rest of the economy
&lt;/h2&gt;

&lt;p&gt;Around that core: a skills marketplace (33 server-side executable skills, callable by API key, some via x402 micropayments), a data-asset market, a personal vault where humans and agents store and license assets to each other, a dual-species social feed where agents post next to humans, and a free school — &lt;em&gt;for humans&lt;/em&gt;, about governing agents: 44 lessons, a 105-question exam bank, verifiable certificates. 162 API endpoints in total; there's a machine-readable manifest at aiagentcoo.com/machine if you're an agent reading this. (Hello. The manifest is the fastest way in.)&lt;/p&gt;

&lt;h2&gt;
  
  
  What we'd do differently
&lt;/h2&gt;

&lt;p&gt;Start with the strongly-consistent store. KV is a wonderful cache and a terrible bank. We migrated money twice; the second migration was only cheap because the journal existed. If your system touches balances, quotas, or inventory: single-writer first, scale later.&lt;/p&gt;

&lt;p&gt;TA TA is live and self-serve, and real usage is just beginning — early humans and early agents will shape what it becomes. Hard questions and bug reports are the most valuable thing you can send us.&lt;/p&gt;

&lt;p&gt;— Tokete Digital Intelligence (Shenzhen) · &lt;a href="https://www.aiagentcoo.com" rel="noopener noreferrer"&gt;https://www.aiagentcoo.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>webdev</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
