ai newsFr., 4. Dez.
EilmeldungAlibaba Releases Qwen4-35B-A3B: Open-Weight MoE Model With 1M Context

Keep a receipt you can re-check for every API call your AI agent pays for (x402)

When an agent pays for API calls on its own, the questions come later. Which rules was it running under? What did it check before it paid? What exactly did it pay, to whom, and did the seller deliver what it says it delivered? A payment log answers part of that, but only if you trust whoever wrote

dev.toFreitag 02:33 · 04.12.3 Min. Lesezeit
Bild: dev.to

Posted on Dec 4 • Originally published at github.com

When an agent pays for API calls on its own, the questions come later. Which rules was it running under? What did it check before it paid? What exactly did it pay, to whom, and did the seller deliver what it says it delivered?

A payment log answers part of that, but only if you trust whoever wrote the log. This post shows one way to keep a single JSON file per payment that anyone can check again, without trusting the agent that wrote it.

I maintain the open-source tool used here ( @agent402-dev/pay-mcp, Apache-2.0, version 0.16.1 or later). Building and checking a bundle signs nothing and pays nothing.

A "proof bundle" is one JSON object per payment:

The hash ties the payment to the rules that were in force. The receipt ties the payment to what the seller says it returned. The transaction ties both to the chain.

The agent pays through the x402_fetch tool under your rules: X402_ALLOWED_DOMAINS, X402_TRUSTED_PAY_TO and the per-payment and daily limits. (If you have not set those up yet, the earlier post on spending caps walks through them.)

The tool's result carries the payment ( network, mint, amount, payTo, settlementTx ) and, when the seller signs receipts, receipt.token. The same payment is also in payment_history.

import { buildProofBundle } from '@agent402-dev/pay-mcp/proof-bundle'; import { policyFromEnv } from '@agent402-dev/pay-mcp/policy'; const bundle = await buildProofBundle ( { policy: policyFromEnv ( process. env ), // the same X402_* rules the agent ran with payment: { resource, network, asset: mint, amount, // integer string, smallest units payTo, transaction: settlementTx, at: new Date ( ). toISOString ( ), }, receipt: receiptToken, // optional } ); Enter fullscreen mode Exit fullscreen mode A malformed amount or at is refused when the bundle is built, so a bad record fails early instead of at audit time. Start-up warnings are not part of the rules and do not change the hash.

Write bundle to a file next to whatever the agent produced with the paid response.

npx -y @agent402-dev/pay-mcp verify-proof --bundle proof.json --rules-from-env Enter fullscreen mode Exit fullscreen mode It prints each check and exits 0 when all pass, 1 when one fails and 2 when the file cannot be read, so it drops into CI or a cron job. What it checks:

The part I care most about: anything it could not check is listed under notChecked instead of being counted as a pass. No rules given, no receipt in the bundle, and so on. A green result never hides a step that did not run.

If agents end up making many small payments without a person watching each one, "the agent's log says so" will not be enough for whoever reviews the spending. A file that can be re-checked against the rules, the seller's signature and the chain is a small step toward payments you can check rather than trust.

The full guide, with the same steps, is in the repository: https://github.com/agent402-dev/agent402-toolkit/blob/main/docs/guides/payment-proof-bundle.md

Internal review only, not independently audited.

Quelle: dev.to (dev.to). Original öffnen