nearx402 spend-policy wallet for AI agents on NEAR

x402, redefined.

Private policy, public proof. An AI agent on NEAR pays per x402 call only after the contract verifies a Groth16 proof that the spend is allowed. The contract, not the agent, holds the money.

Policy contract … on … · read-only, this page holds no key · RPC …
Loading…

Verify the deployment every row is read from the chain at final; nothing here is typed in

…ReadingWaiting for the first RPC answer.
Wallet balance
–
held by the contract, not the agent
Paid today
–
UTC day
Payments
–
token transfers that settled
Blocked attempts
–
logged on chain, no transfer
Circuit breaker
–
blocked today / limit

Agents

Approved vendors

How one payment is decided two NEAR transactions, the rest is HTTP

HTTP1
402 from the vendor
Price, token and a nonce that lives five minutes.
local2
Agent proves
A Groth16 proof that the payment fits its cap, per-call limit and allowlist. About 200 ms, 256 bytes.
NEAR3
Contract verifies and pays
pay_zk: the proof is checked on chain, then the contract itself transfers the tokens and writes the log entry.
HTTP4
Agent retries with a receipt
Contract id, log number, nonce, transaction hash and a secret only the agent knows.
reads NEAR5
Facilitator checks
Code hash, log entry, token transfer event, nonce and receipt secret. It holds no key and sends nothing.
HTTP6
200, once
The same receipt again gets 402: already redeemed.
A blocked attempt stops at step 3: the proof fails, nothing moves, the attempt is logged.Five blocked attempts in one UTC day freeze the agent.

Audit log

#Time (UTC)AgentVendorAmountStatusDetailMemoTransaction

Check it yourself

On the explorer

Recorded transactions

  • None listed for this run.

From a clone, no accounts and no funds

scripts/demo-zk.sh starts a local NEAR sandbox and runs the whole flow: one paid call, the replay rejected, two attacks blocked. It exits non-zero if any outcome differs from the README's table.

scripts/demo-zk.sh --network testnet does the same against the contract above, after checking that the chain holds the expected build.

Stated plainly

  • The testnet contract is not locked: the key holder can replace its code. The policy holds against the agent, not against the team.
  • The circuit has no third-party audit and its setup ran on one machine.
  • The token is a mock with no value. This is a hackathon build.