agents/x402: an agent wallet that pays over x402 only what the agent's ledger records and its policy allows, run on the public testnet

The agent does not hold the payment key: the wallet holds it for the owner and signs an EIP-3009 authorization only for a payment the
agent wrote into its signed ledger, verified without trusting the agent under the policy the owner pinned and against the ledger heads
the wallet itself saw (a branch is refused with a proof of equivocation, a backdated entry is refused), naming exactly this purchase,
written now, and within the limit judged also against what the wallet itself has signed. The authorization nonce is sha256(entry hash),
so the on-chain payment names the ledger entry. The policy gains an optional `wallet` field. Also: an x402 v2 client, a minimal resource
server, a local facilitator for tests, and verifica-plati.mjs, which proves from outside that a wallet's on-chain payments were allowed
by the agent's policy (with --all-transfers, that no payment left the wallet without a ledger entry).

Tests: wallet 25/25 and payment verifier 10/10 without a network (the verifier on chain responses recorded on testnet 28001), negative
control 21/21; policy 27/27, agents control 26/26. On the public testnet 28001 through its x402 facilitator: 9/9, with the evidence in
agents/x402/dovezi-28001/. Needs ethers (npm install in agents/x402).
This commit is contained in:
Aere Network committed 2026-09-30 00:01:34 +03:00
1 parent 35d711fa55
commit 2293c1da86
19 files changed
+1401 -24

No files matched your search

+10 -3
View File
@@ -25,7 +25,8 @@ node agent-cli.mjs verify-equivocation --proof proof.json
```
A spec is `{ agentId, spend: { amount, windowSeconds, asset? }, tools: [...], recipients: [...], approval: { approvers: [humanId...],
threshold, above?, tools? }, owner: humanId }`; every field but `agentId` is optional. An action is `{ kind: "payment", to, amount,
threshold, above?, tools? }, owner: humanId, wallet: 0x<EVM address> }`; every field but `agentId` is optional. When `wallet` is
named, a payment must say `from` and be from it. An action is `{ kind: "payment", to, amount,
asset? }` or `{ kind: "tool", tool, args? }`; the ledger sets its time. Exit codes: 0 yes (allowed, valid, found), 1 no (invalid,
not found, refused by a check), 3 an action refused by the policy, 2 wrong usage. Private keys stay in their files and are never
printed; the tool creates them with mode 0600, which has no effect on Windows (protect the folder there).
@@ -51,6 +52,12 @@ printed; the tool creates them with mode 0600, which has no effect on Windows (p
a validity window of at most seven days and a nonce that counts once per ledger. Only approvers named in the policy count, each
once. A revocation is signed by the owner named in the policy; from its time on every action is refused.
## Paying over x402
`x402/` holds the agent wallet: a service that keeps the payment key for the owner and signs an x402 payment only when the agent's
ledger records it and the policy allows it, with the wallet as the witness of the ledger's heads and time. It was run end to end
on the public testnet 28001 on 2026-09-29, and the evidence is there with a verifier anyone can run. See `x402/README.md`.
## What the verifier can and cannot see
- **Time.** An entry's time is the statement of whoever holds the agent key. The verifier bounds it from above with its clock. It
@@ -72,11 +79,11 @@ Measured on 2026-09-29 (Node.js 24.14.1, Windows):
| test | result |
|---|---|
| `node proba-agent-policy.mjs` | 23/23 with the AIP-23 reference verifier (`AERE_VERIFY_PROOF=<verify-proof.mjs from aere-node>`); without it 21 run, 2 are reported as skipped and the exit code is 2 |
| `node proba-agent-policy.mjs` | 27/27 with the AIP-23 reference verifier (`AERE_VERIFY_PROOF=<verify-proof.mjs from aere-node>`); without it 25 run, 2 are reported as skipped and the exit code is 2 |
| `node proba-agent-ledger.mjs` | 51/51: limits over the ledger, identity, tampering, a re-signed false decision, a looser policy under the real hash, backdating (refused when written; caught with anchors or `notBefore`), a branch, equivocation proofs, resuming |
| `node proba-agent-aprobare.mjs` | 39/39: threshold, unnamed or repeated approvers, classical keys, another action or other tool arguments, reused nonces (also after a restart), expiry, approvals across branches, revocation, an omitted revocation |
| `node proba-agent-cli.mjs` | 23/23 on Windows, through files and processes only; on Linux and macOS one more test checks the 0600 mode of the key (not measured here) |
| `node control-negativ-aprobare.mjs` | 25/25: each guard is removed in a copy, one at a time, and the named test must fail for that reason; a test that stops before its summary counts as a failure of the control |
| `node control-negativ-aprobare.mjs` | 26/26: each guard is removed in a copy, one at a time, and the named test must fail for that reason; a test that stops before its summary counts as a failure of the control |
The data format is version 2 (2026-09-29). Code comments, test names and most internal names are in Romanian; messages, data and
the exported interface are in English. No third party has reviewed this component.