DEV Community

Cover image for Guard rails for AI agents that pay: five free checks on a ledger of 3.8 million payments, with code you can run
AFG
AFG

Posted on

Guard rails for AI agents that pay: five free checks on a ledger of 3.8 million payments, with code you can run

An AI agent with a wallet pays whatever its model decides to pay. That is the point of giving it a wallet, and it is also the problem. A page the agent reads can tell it to pay. An address can look like one it paid yesterday. A key can leak. The chain settles all of these the same way, in seconds, and the model that should object is the part being steered.

So the check has to sit outside the model: a second opinion that reads facts the agent cannot talk its way around.

We run Agentic Finance Graph, an independent ledger of the money AI agents hold and pay, read from the chain. This article walks through five checks built on it. Each one is free, needs no key and no account, and answers in JSON over HTTPS. Every JavaScript file, curl line and npx command below was run on 17 November 2026 exactly as printed, and the output shown under a block is what came back.

The ledger under the checks

ERC-8004 gives an agent a registration on chain. We read every registration on Base, follow the wallets bound to them, and count what those wallets pay after the agent registered. On 17 November 2026:

Measured on Base 17 November 2026
Agent registrations read on Base 1,207,271
Agents seen paying after they registered 31,425
Counted payments 3,827,299, worth $58.77M
Median counted payment $0.05
Addresses that received them 30,186

Counted payments are not all commerce, and the ledger says so. Of the $58.77M, $26.95M (46%) went into lending and vault positions the payers still hold. $31.83M left the payers' control.

You can read the same figures in one line:

npx -y agentic-finance-graph state
Enter fullscreen mode Exit fullscreen mode

A few of its lines:

as of 2026-11-17T21:45:21.484Z
observed_pay_usd_total               58772547.223887  USD  2026-11-17T21:28:19.575Z
observed_pay_usd_own_positions       26945901.487947  USD  2026-11-17T19:51:05.475Z
observed_pay_usd_left_control       31826004.623793002  USD  2026-11-17T19:51:05.481Z
actors_l7_plus                                 31425  actors  2026-11-17T20:55:38.877Z
observed_pay_usd_median                         0.05  USD  2026-11-17T21:28:19.580Z
...
Enter fullscreen mode Exit fullscreen mode

Each line is a figure, its unit and the time it was measured. Each figure has a definition at agenticfinancegraph.com/def/<id> that says what it means and what it does not.

1. Before the payment: ask the Gate

Send the paying agent, the address it is about to pay and the amount in USD. The Gate reads nine measured facts about the payee. Among them: whether the address is a look-alike of one the agent has paid or was funded by, whether it passes on what it receives within ten minutes, whether it is an EIP-7702 account delegated to a sweeper, and what it is usually paid. It compares the payment with the agent's own history, applies your policy, and answers allow, log, warn or block with every reason.

The policy is yours. Name one of ours, or send your own: allowed payees, an amount range, a budget and a recurrence in the AP2 constraint vocabulary, plus caps for new payees. A constraint the Gate does not know blocks before any rule runs, so a typo cannot silently allow.

A limit that cannot be split

Take a policy that says: at most $50 in 24 hours to a payee the agent has never paid. A steered agent that wants to send $80 sends $40 twice. The second payment follows the first by seconds, long before a ledger has counted the first one. Ours counts a payment a median of 159 minutes after its block (measured on 17 November on the 8,146 payments of the three days before), because a payment is counted only after its receipt has been read and checked.

So the Gate also counts what it has already let through for the same caller in the last 12 hours and has not yet seen on chain. The caller is a client_ref: a random string your client keeps in its own configuration and sends with every check.

// gate-split.mjs: one agent, one address it has never paid, and a limit of $50 a day for a new payee.
// Node 18+, no dependencies, no key.
import { randomBytes } from "node:crypto";

const GATE = "https://agenticfinancegraph.com/api/gate/check";
const clientRef = randomBytes(16).toString("hex");            // in production: one fixed value from your configuration
const payee = "0x" + randomBytes(20).toString("hex");         // an address the agent has never paid
const policy = { new_payee: { max: 50, window_hours: 24 } };  // at most $50 in 24 hours to a payee that is new

async function ask(amountUsd) {
  const r = await fetch(GATE, {
    method: "POST",
    headers: { "content-type": "application/json" },
    body: JSON.stringify({ agent: "57657", payee, amount_usd: amountUsd, policy, client_ref: clientRef }),
  });
  const j = await r.json();
  return { decision: j.decision, reasons: j.reasons, pending_usd: j.context.pending.usd, receipt: j.decision_id };
}

console.log("first  $40:", await ask(40));
console.log("second $40:", await ask(40));
Enter fullscreen mode Exit fullscreen mode
first  $40: {
  decision: 'allow',
  reasons: [],
  pending_usd: 0,
  receipt: 'gd_da18b13824de91dce88a6249'
}
second $40: {
  decision: 'block',
  reasons: [ 'new_payee_window_above_max:40+40>50/24h' ],
  pending_usd: 40,
  receipt: 'gd_196a18f06331faf671fe8021'
}
Enter fullscreen mode Exit fullscreen mode

The first check is allowed. The second is refused, and the reason says why: 40 already let through plus 40 asked is above 50 in 24 hours. No payment was made in between. The Gate counted its own earlier answer.

Three things to know:

  • Another caller does not see your pending amounts. A stranger asking about your agent cannot use up its limits.
  • Keep client_ref outside the model's reach, in the configuration of your payment hook. A steered agent must not be able to change it.
  • An allowed check that is never paid still counts against your own limits for those 12 hours. Use a fresh reference while you test.

The rule and its five tests were written down before any code. All five gave the registered result, and 191 stored decisions replayed under the new rule gave the same decision and the same reasons as under the rule it replaces. The definition is public: gate.context.v2.

The Gate advises. It never blocks a payment itself: your code reads the answer and decides. If you use an x402 client, the Integrate page has a hook that asks the Gate after your own spend controls and before anything is signed.

2. Keep the receipt, and check it yourself

Every Gate answer carries a receipt: the agent, the payee, the amount, the policy and its hash, the decision, the reasons and the time, signed with an Ed25519 key we publish. When someone later asks why your agent paid, you can show what was known at the moment of the decision. And you do not have to take the answer on trust:

// verify-receipt.mjs: ask the Gate once, then check its receipt without trusting the answer.
// Node 18+, no dependencies, no key.
import { createHash, createPublicKey, verify } from "node:crypto";
const SITE = "https://agenticfinancegraph.com";

const answer = await (await fetch(SITE + "/api/gate/check", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ agent: "57657", payee: "0x4cd00e387622c35bddb9b4c962c136462338bc31", amount_usd: 25, policy_name: "recommended-v3" }),
})).json();
const receipt = answer.receipt;

// the public key, from a file that is not the answer
const keys = await (await fetch(SITE + "/.well-known/afg-pass-keys.json")).json();
const hex = keys.keys.find((k) => k.key_id === receipt.key_id).public_key_hex;
const spki = Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), Buffer.from(hex, "hex")]);
const publicKey = createPublicKey({ key: spki, format: "der", type: "spki" });

const bytes = Buffer.from(receipt.canonical, "utf8");          // the exact text that was signed
const hashOk = createHash("sha256").update(bytes).digest("hex") === receipt.sha256;
const signatureOk = verify(null, bytes, publicKey, Buffer.from(receipt.signature, "base64"));

const signed = JSON.parse(receipt.canonical);                   // read the claims from the signed text only
console.log({
  hash_ok: hashOk,
  signature_ok: signatureOk,
  decision: signed.decision,
  amount_usd: signed.amount_usd,
  policy: signed.policy.name,
  decided_at: signed.decided_at,
  does_not_assert: signed.does_not_assert,
});
Enter fullscreen mode Exit fullscreen mode
{
  hash_ok: true,
  signature_ok: true,
  decision: 'allow',
  amount_usd: 25,
  policy: 'recommended-v3',
  decided_at: '2026-11-17T21:47:08.812Z',
  does_not_assert: [
    'That a payment was made, or that the client followed this answer.',
    'That the payee or the agent is safe. The answer is advisory: the client decides.'
  ]
}
Enter fullscreen mode Exit fullscreen mode

The payee in this example is a contract that 1,110 registered agents have paid, usually about $10 at a time: two of the facts the Gate reads.

The last two lines of the output are part of the signed text. A receipt says what was answered. It does not say that a payment was made, and it does not say that the payee is safe.

3. When you are the one being paid

A seller or a platform can ask what the ledger holds about the wallet on the other side.

// who-is-paying.mjs: you sell something and a wallet has just paid you. What does the ledger hold about it?
// Node 18+, no dependencies, no key.
const wallet = "0x024beeed33d76cce272c0db022134cda921f4aa6";
const p = await (await fetch("https://agenticfinancegraph.com/api/payer?wallet=" + wallet)).json();

console.log({
  registered_agent: p.registered_agent,
  agent: p.agent && { id: p.agent.token_id, level: p.agent.level, last_payment_at: p.agent.last_payment_at,
    open_incidents: p.agent.open_incidents, pass_holds: p.agent.pass_holds, watch_newest: p.agent.watch_newest },
  worth_a_look: p.worth_a_look,
  cannot_see: p.cannot_see,
});
Enter fullscreen mode Exit fullscreen mode
{
  registered_agent: true,
  agent: {
    id: '57657',
    level: 9,
    last_payment_at: '2026-11-17T16:44:15.848Z',
    open_incidents: 0,
    pass_holds: true,
    watch_newest: 'none'
  },
  worth_a_look: [],
  cannot_see: 'Who holds the key, wallets on other chains, and anything after the measurement times inside the self-check.'
}
Enter fullscreen mode Exit fullscreen mode

worth_a_look lists what our data flags, each item with its source. An empty list means nothing in our data is worth flagging at those times. It does not mean the payer is safe.

A wallet with no registration answers registered_agent: false. That is not a statement about the wallet: most wallets are not registered agents, and an agent can pay from a wallet it never bound.

4. When an agent has to show who it is: the Pass

The Agent Pass is eight checks on one agent at one moment:

  1. it is ranked: seen paying after it registered
  2. no open incident of a harmful kind
  3. a counted payment in the last 30 days
  4. its newest payment is in character for it
  5. no issuer freeze on a bound wallet
  6. no unlimited approval to a plain key
  7. no incident of a harmful kind in 90 days
  8. a month without a payment out of character

A Pass that holds is signed and valid for three hours. It comes as JSON, as a JWT, or as a W3C Verifiable Credential, so the other side can verify it with tools it already has.

// verify-pass.mjs: read an agent's Pass and accept it only if the signature and both time rules hold.
// Node 18+, no dependencies, no key.
import { createPublicKey, verify } from "node:crypto";
const SITE = "https://agenticfinancegraph.com";

const doc = await (await fetch(SITE + "/api/pass?agent=57657")).json();
if (!doc.signed_pass) { console.log({ holds: false, fails: doc.pass.fails, not_checked: doc.pass.not_checked }); process.exit(0); }
const { canonical, signature, key_id } = doc.signed_pass;

const keys = await (await fetch(SITE + "/.well-known/afg-pass-keys.json")).json();
const hex = keys.keys.find((k) => k.key_id === key_id).public_key_hex;
const spki = Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), Buffer.from(hex, "hex")]);
const publicKey = createPublicKey({ key: spki, format: "der", type: "spki" });

const signatureOk = verify(null, Buffer.from(canonical, "utf8"), publicKey, Buffer.from(signature, "base64"));
const pass = JSON.parse(canonical);                              // the claims, from the signed text only
const issued = Date.parse(pass.issued_at), expires = Date.parse(pass.expires_at);
const shortLived = expires - issued <= 3 * 60 * 60 * 1000;       // rule 1: a Pass lives three hours at most
const notExpired = expires > Date.now();                         // rule 2: by your clock, not by ours

console.log({
  accept: signatureOk && shortLived && notExpired,
  signature_ok: signatureOk,
  short_lived: shortLived,
  not_expired: notExpired,
  agent: pass.agent.token_id,
  level: pass.level,
  rules: pass.definitions,
});
Enter fullscreen mode Exit fullscreen mode
{
  accept: true,
  signature_ok: true,
  short_lived: true,
  not_expired: true,
  agent: '57657',
  level: 9,
  rules: [
    'agent.pass.v3',
    'rank.l7plus.v2',
    'behaviour.out_of_character.v3',
    'issuer.freeze.v1',
    'detection.logged.v1'
  ]
}
Enter fullscreen mode Exit fullscreen mode

The two time rules matter. The dates inside a Pass are the signer's own statement, so a verifier accepts a Pass only if it lives three hours at most and has not expired by the verifier's own clock.

At 21:32 UTC on 17 November, 24,441 of the 31,426 ranked agents held a Pass. The most common reason for not holding one is the simplest: no counted payment in the last 30 days. A Pass is about now. An agent that stops paying stops holding one.

A Pass says holds or does not hold. It never says safe.

5. Your own agent, or your whole fleet

The self-check is everything above about one agent in one answer: its level, its Pass, the Watch reading on its newest payment, the token approvals it gave in the last 30 days, detections, and its blast radius, which is what a stolen key for its wallets would control at one block. The answer ends with the items worth a look, each with its source.

# one agent
curl -s "https://agenticfinancegraph.com/api/self-check?agent=57657"

# up to 60 agents in one answer, the ones worth a look first
curl -s "https://agenticfinancegraph.com/api/fleet?agents=57657,45978,99924"
Enter fullscreen mode Exit fullscreen mode

The fleet check also takes owner=0x... and returns every registration that wallet holds.

What runs behind the answers

The Watch. It scores a counted payment against the paying agent's own earlier payments, with public reasons: an amount outside its usual range, a new payee at a new size, a small probe followed by a large payment to the same address. 3,401,885 payments of 28,249 agents are scored so far. On the evaluation set fixed in October, with the thresholds fixed before the run, it called out 13 of the 15 harmful payments it could score and 301 of 319 planted drains, at 37 alerts across 47.7 agent-years of agents with no known incident.

Drain alerts that read the transaction first. A wallet that empties itself is not always a wallet being robbed. Before an alert is raised, the reader opens the transaction. An exchange (the wallet got back at least 90% of the value that left it), a deposit into the wallet's own position, or a bridge to the same address on another chain is the wallet's own move, and bridges are followed to six other chains. What came back is measured against everything that left the wallet in that transaction, so a transaction that swaps and also sends value elsewhere does not read as an exchange.

Agent Books. One agent's month as a signed statement: what it paid, what it received, and what was left out and why. The hash of each statement is in a signed log, and a daily Base transaction commits to that log, 18 of them since 1 November. An accountant, an auditor or a counterparty can check a statement without trusting our server.

Rules first, results second. Every rule above has a public definition with a version number, and a change is a new version. The versions in force of the Watch, the Pass, the drain reader and the Gate's pending count were each written down, with their tests, before they were measured. Changes are dated entries in a public register: 81 entries so far.

Checked from outside. One team wrote its own verifier for our signed statements. Another re-ran our public fixture row by row with its own reader.

One measurement from this week

In the 24 hours to 08:48 UTC on 17 November we counted 611,295 stablecoin transfers into the seller addresses listed in the x402 Bazaar on Base. The day before, the count was 236,903.

We read an evenly spaced sample of 2,500 of them. One seller address received 2,219 (89%), and 55 other sellers shared the rest. 2,484 of the 2,500 were signed authorisations, and 2,478 of those were put on chain by a facilitator.

Two limits. This is a count of transfers into listed seller addresses, not of purchases. And when one seller takes most of a sample, the shares describe that seller more than the market. The document is public:

curl -s https://agenticfinancegraph.com/api/x402-submitters
Enter fullscreen mode Exit fullscreen mode

What these checks do not say

  • Not a verdict. Each answer is measured facts with their sources and times. A clean answer means nothing in our data fired at those times.
  • Not a block. The Gate is advisory. We record what we answered. What happens next is your code's decision.
  • Not an identity. We work with registration numbers and addresses. We do not say who holds a key.
  • Not every chain. The checks read Base: ERC-8004 registrations there and stablecoin payments there.
  • Not a prediction. A Pass says what held at one moment. Nothing in it speaks for the next three hours.

Try it

# the state of agent money on Base, in your terminal
npx -y agentic-finance-graph state

# the same data as 29 read-only MCP tools, no key (Claude Code shown; any MCP client can use the URL)
claude mcp add --transport http afg https://agenticfinancegraph.com/mcp
Enter fullscreen mode Exit fullscreen mode

Everything in this article is free and needs no account. You pay cents when you want one dated file about one agent, and a flat amount for 30 days when you run a fleet on a standing watch: pricing.

If you run an agent that pays and there is a check you are missing, tell us in the comments. The hard cases are the ones we want to hear about.

Figures measured on 17 November 2026: the ledger between 19:51 and 21:28 UTC, the Pass count at 21:32 UTC, the x402 count on the 24 hours to 08:48 UTC. Code run between 21:47 and 21:48 UTC.

Top comments (0)