← Blog
November 25, 2026 · 16 min

Paid only if proven: what a zk proof costs an x402 inference payment

A proposal in the x402 repository wants an inference payment to release only when a zero-knowledge proof shows that a pinned circuit turned the buyer's input into the delivered output. We rebuilt the reference circuit, proved it on our own hardware, ran our proofs against the verifiers deployed on Base Sepolia and priced the gas on Base mainnet. The condition holds. At a one-cent price it costs three quarters of the payment.

As the issue puts it, x402 today pays the server on the server's own word. exact settles whatever comes back. auth-capture captures when the operator decides. batch-settlement claims the vouchers the server holds. For most API calls that is fine: reputation and repeat business do the enforcing.

Paid inference is the case where it is least fine. The buyer cannot cheaply check that the model it chose actually ran on its input. Issue #4390, opened on 23 November by achemperety, proposes to close that gap with a release condition: no valid proof, no payment.

The thread moved fast. Thirteen comments in two days, all from two participants: the author and zambodotdev. No maintainer has answered yet. In that time the draft went from a dedicated scheme (v0.1, 24 November) to a condition attached to existing schemes (v0.2, this morning). The reference code is public in achemperety/exactzk-zk-inference-escrow, tag v3.0.0-testnet, deployed on Base Sepolia. It is unaudited and its README says so first.

We have looked at the escrow this rides on in our auth-capture audit, and at the hardware route to model identity in our attested inference audit. This post measures the cryptographic route. We regenerated both verifying keys from the published files, produced fresh proofs, checked them against the deployed verifiers, broke them on purpose, sampled Base mainnet fees and read x402 main at b03ad99 for every part the draft depends on.

What the condition says

Every proof is checked against one statement, per lane: "the circuit of entry verifierId maps the input committed to by commitments[i] to outputs[i]". The solo circuit has one lane: one input commitment and ten outputs, eleven public inputs in all.

The model behind it is small and honest about it. A multilayer perceptron, 784 → 64 → 32 → 10, with 52,650 parameters, classifying handwritten digits. Inputs and weights are fixed-point numbers scaled by 213. Each input carries five extra nonce values that the network ignores and the Poseidon input commitment includes, so two buyers sending the same image get different commitments.

The proof condition draft defines three outcomes and forbids merging them:

OutcomeWhenWhat it tells the parties
ValidThe registered verifier ran on the registered code and acceptedThe condition holds
InvalidThe registered verifier ran and did not accept, or the output does not fit the entryThis proof will never pass
UnverifiableUnknown entry, an entry that is not the registered one, or code that is not the registered codeNothing was decided; the same proof may pass later

The interesting design choices sit around that table. Anyone may present a proof, so the payer cannot block a payment it already authorized by withholding cooperation. Because anyone may present, a failed proof reverts and records nothing. Otherwise a stranger could pin an "invalid" verdict on someone else's payment for the price of gas. The payment's history is terminal only: settled against a proof, given back by the payee, or returned through the host scheme's own exit.

One more rule closes a quieter attack. The verifier must receive the full gas its registry entry names. A transaction that cannot supply it reverts with InsufficientGasForVerifier, never with "invalid". Otherwise a submitter could make a valid proof fail by under-funding it.

The core rule — a proof failure is an error, not an outcome. "Could not be checked" must never degrade into "invalid" by default, because the next step is opposite: retry later in one case, never in the other.

The boolean in x402's policy hook

The draft attaches to the auth-capture EVM binding, which already reserves a third operator type, "policy", for exactly this kind of contract-checked condition. The binding's appendix even lists "oracle-conditioned release" among its intended uses. Its hook is a read-only predicate that returns a boolean:

if (!ICaptureAuthorizer(policy).authorizeCapture(paymentInfo, amount, feeAmount, feeReceiver, "")) {
    revert AuthorizationDenied();   // mapped to invalid_auth_capture_evm_policy_denied
}

For a proof, that false collapses the two outcomes the condition needs apart. A server that sees policy_denied cannot tell a tampered proof from a verifier whose code changed. It either retries a proof that will never pass, or gives up a payment it could still capture.

The policy profile replaces the boolean with a bytes32 status word: Authorized, ProofInvalid, VerifierUnavailable or Denied. The zero word is none of them, so a contract that answers with zeros never reads as authorized. Unknown words map to policy_denied, never to proof_invalid. Two new error codes are proposed: invalid_auth_capture_evm_proof_invalid and invalid_auth_capture_evm_verifier_unavailable.

The second gap is data. The appendix passes "" as the hook's last argument, and the operator ABI has no parameter for policy data. The reference policy needs one: its ProofData struct carries the output and the proof itself, because the view check runs the verifier on them. This morning zambodotdev argued for a hash-only policyData. That would keep logs small, but a hook that only sees a hash cannot run the verifier, so the check would have to live somewhere else. The thread has not resolved it.

Until the "policy" type exists, the reference runs the same check through a "custom" operator fixed to one policy at deployment. The escrow's plain charge is disabled there; captureWithPolicy is open to anyone and pays only the receiver the payer signed for.

We rebuilt the circuit and proved it ourselves

A proof condition is only as good as the claim that a registry entry stands for a given model. So we started there. With EZKL 23.0.5 (the current PyPI release), the published ONNX files, the pinned settings.json files and the two pinned SRS files (whose SHA-256 values matched the repository's pins), we regenerated both verifying keys from scratch.

Both matched. The solo key hashed to 0x13cff042…4ff2 and the eight-lane key to 0xdd03fb0c…675f, the values the manifest and the registry entries carry. On Base Sepolia, the deployed solo verifier's code hash is 0x8cd0b80f…5f49 over 17,992 bytes, and the eight-lane verifier's is 0x471c8109…7ef1, both as pinned.

Then we proved. Our machine is two 2014-era Xeon E5-2699 v3 sockets, 72 threads. The reference measured a 2-vCPU cloud slice and, in September, a Mac:

StageSolo, oursSolo, reference (2 vCPU)K=8, oursK=8, reference (Mac)
Key setup6.3 s, 1.22 GB18.25 s, 960 MB41.9 s, 9.54 GB15.1 s, 6.35 GB
Witness0.44 s0.23–0.29 s2.9 s0.82 s
Proof6.5–6.7 s, 1.69–1.72 GB20.1 s, 1,393 MB44.1–46.4 s, 11.5–11.7 GB19.1 s, 12.8 GB
Off-chain verify0.11 s—0.74 s0.15 s
Proving key658,663,971 bytes5,269,293,603 bytes

Times depend on the machine. Memory stays in the same range: the eight-lane prover needed more than 11 GB on both machines, and its proving key alone is 5.3 GB.

Our solo proof's public inputs came out byte-identical to the stored proof's: same input, same commitment, same ten outputs. The proof bytes differ, as Halo2's blinding makes them. For the eight-lane circuit we built our own input, eight lanes with nonces nobody had used, so that proof is for commitments that did not exist before this morning.

Both proofs pass the deployed verifiers. An eth_call to the solo verifier on Base Sepolia with our proof returns 1; eth_estimateGas puts the bare call at 670,465 gas, of which 21,000 is intrinsic and 65,484 is the 4,356 bytes of calldata. The eight-lane call estimates at 756,143. Then we added one fixed-point unit to the last output and tried again. EZKL answered "the constraint system is not satisfied", and both deployed verifiers reverted.

That is the mechanism working as claimed: a pinned circuit, a fresh input, a check anyone can run against public code, and a one-unit lie that fails.

The gas, priced on Base mainnet

The reference's headline figure is a one-transaction settle at 766,226 gas on Base Sepolia. We read that receipt back: status success, 766,226 gas, 5,028 bytes of calldata, 0.006 gwei, an L1 data fee of 3,690 wei. Of a solo settlement, 577,544 gas is the generated Halo2 verifier.

To price it on mainnet we sampled Base at 09:05 UTC today. eth_gasPrice was 0.006 gwei on a 0.005 gwei base fee. Across the previous 44,032 blocks, roughly a day, the base fee sat at 0.005 gwei at the median and 0.00509 gwei at the 95th percentile, peaking at 0.00664. ETH traded at $1,645.98 on CoinGecko.

For a baseline we needed the cost of the payment proof gating replaces. In 200 recent Base blocks we found 90 bare USDC transferWithAuthorization transactions, ones that emitted only Transfer and AuthorizationUsed. Their median was 86,466 gas, and they paid a median effective price of 0.01 gwei, above the base fee.

TransactionGasUSD at 0.006 gweiUSD at 0.010 gweiShare of $0.01
Bare EIP-3009 settle (Base mainnet, median)86,466$0.00085$0.001429–14%
Proof-gated settle (Base Sepolia receipt)766,226$0.00757$0.0126176–126%
auth-capture + proof policy, USDC (local)899,361$0.00888$0.0148089–148%
batch-settlement claim gate, steady (local)769,210$0.00760$0.0126676–127%
K=8 batch, one channel, per request (Base Sepolia)107,539$0.00106$0.0017711–18%
K=16 batch, sixteen channels, per request (local)71,066$0.00070$0.001177–12%

The L1 data fee does not change the picture. Base's gas price oracle returns an upper bound of $0.000048 for a 5,200-byte transaction, about 0.6% of the L2 fee of a solo settle.

Why one cent? Because that is the price the reference's own quickstart pays, and it is also what our gateway quotes for a short completion: we probed four models this morning and each 402 asked for 10,000 atomic units of USDC on Base. At that price a solo proof-gated payment spends three quarters of the money on gas at today's base price, and more than all of it at the price bare settlements actually paid. Under the "custom" route the facilitator relays only the collect call; the capture, 750,718 gas with USDC in the local run, is submitted out of band, and whoever submits it pays.

Batching is what changes the economics. At sixteen requests per proof the per-request cost falls below a bare exact settle. Two caveats travel with that row: the K=16 verifier was regenerated from its key for measurement and is neither registered nor deployed, and the prover memory grows with the batch. The repository also carries a Groth16 prototype at 372,965 gas, flagged experimental: single-party setup, and a different input commitment, so not the same statement.

The stock client cannot opt in

Under the "policy" type the receiver authorizer signs every capture on chain, so it cannot be a key nobody holds. The profile therefore binds the terms through the one input the client still controls, its contribution to the salt:

saltNonce = uint256(keccak256(abi.encode(PROOF_TERMS_TYPEHASH, verifierId, inputCommitment)))
salt      = uint256(keccak256(abi.encode(SALT_BINDING_TYPEHASH, receiverAuthorizer, policy, saltNonce)))

x402's own clients do not do that. In the TypeScript client at b03ad99, the line is const saltNonce = generateSalt();, and generateSalt fills 32 bytes with crypto.getRandomValues. The Go client calls authcapture.GenerateSalt(). The Python SDK has no auth-capture mechanism at all.

The consequence is benign but total. A stock client's hold opens to no terms, every capture attempt answers Denied, and the money returns to the payer at the capture deadline. The payer is safe. The server never gets paid.

The reference keeps a second route for unmodified clients. There the server publishes the terms as extra.receiverAuthorizer, an address derived from the verifier and the input commitment, and the stock client binds that address into its salt without knowing what it means. The client gets escrow safety: amount, recipient, reclaim after the deadline. But the proof condition holds only for a client that recomputes the authorizer from the terms it meant to buy. The draft prints the collision bounds: about 2160 work if the client adds randomness after the server names the verifier, 280 otherwise. The salt-nonce route lifts those to 2256 and 2128.

Either way, the buyer's SDK has to change before a proof-gated sale is real. The draft requires the client to draw fresh randomness into its commitment after the server names the verifier, and to refuse terms whose verifier differs from the one first offered. Neither x402 client that implements auth-capture has a place to put that logic today.

batch-settlement: the receiver can walk around the gate

The second host is a proposal, not a profile, and the reason is structural. In x402BatchSettlement, a voucher signs only Voucher(bytes32 channelId, uint128 maxClaimableAmount). There is no room for a per-request commitment. And claim admits two callers: _isReceiverSide returns true for the channel's receiverAuthorizer or its receiver.

The proposal has the client sign one root over the batch's input commitments, and a gate that claims only for proven, included commitments. The author found that a gate acting as receiverAuthorizer is not enough: the receiver can call claim directly and never touch it. So the gate must also be the receiver. The prototype costs 769,210 gas per claim, steady, in a local run.

The last exchange this morning sharpened the payout rule. If the gate required the claimant to be the payee, presentation would stop being permissionless. The two participants agreed on the alternative: each commitment names its payee inside the signed root, the gate pays that address whoever presents, and the address is never a claim input, so there is nothing for a presenter to redirect. The author plans to update the proposal and the prototype accordingly; neither carries the change yet. We covered how custody and refund consent already reshape this contract in our voucher custody audit; a proof gate would be a third party in the same room.

What the proof does not say

A verifierId pins code, not a model. Four reproducible steps lead from a model file to the deployed bytecode, and only the first, key setup, needs the weights. Which model an entry is supposed to stand for is a statement by whoever publishes the model, and the draft says it needs their signature. The circuit is also a rounded copy: a fixed-point quantisation, so its outputs are those of the quantised model, not the original floating-point one.

That has a sharp edge for closed weights. In a September update on ethresear.ch, the author pointed out that for a closed-weight model an outsider can only ever check the link from verifying key to bytecode, never the link from weights to key. Deployment integrity, yes. Lineage, no.

Then there is scale. The reference model has 52,650 parameters. The author's own estimate in the original post puts the practical ceiling for this approach at low tens of millions of parameters on commodity hardware. The best-known research result for language models, zkLLM (ACM CCS 2024), reports a correctness proof for the entire inference process of a 13-billion-parameter model in under 15 minutes, from a CUDA prover, with a proof under 200 kB. That model is about 247,000 times larger than the reference one. And 200 kB posted as calldata is 3.2 million gas at 16 gas per byte, before a single verification step runs.

What it means for LLM4Agents

For the models agents actually buy from us, proof gating is not on the table. Our catalog is hosted language models, most of them closed-weight frontier models served by their providers. Only the party running the weights could produce such a proof, and a 13-billion-parameter model is already five orders of magnitude past the reference circuit. For model identity on those routes, hardware attestation remains the practical path.

Where it does fit is the small-model layer around an agent: classifiers, routers, scorers, policy checks. Those are models of the size this reference proves today, and they are the ones whose output a buyer most needs to trust without re-running them. If we ever sell such a model per call, the "policy" composition is the right shape, because it rides an escrow that already exists instead of a scheme of its own.

The economics are the constraint. Our short-call quote is one cent. A solo proof-gated payment would hand 76% to 126% of that to gas. Keeping gas under a tenth of the price would need roughly $0.08 per call at today's 0.006 gwei and $0.13 at what bare settlements paid, or batches of eight to sixteen.

The status-word argument applies to us now, proof or no proof. "We could not check" and "we checked and it failed" are different answers with different next steps. Our audit of the three SDKs' invalid-reason vocabularies already found two of them disagreeing on whether a garbage signature is terminal or retryable. Any condition we put in front of a settlement should keep the two apart.

Staying on the frontier

In order, from cheapest to most involved.

Track the two maintainer questions. Whether the reserved "policy" hooks may return a status word instead of a boolean, and whether the operator ABI and the capture payload carry policyData. Both decide whether any contract-checked condition, proof or not, can report why it refused.

Make the buyer side able to bind terms. The minimum upstream change is small: let the auth-capture client accept a caller-supplied saltNonce instead of always calling generateSalt(), with the fresh-randomness and same-verifier checks next to it. Without that, no agent on a stock SDK can buy a proof-gated call, whatever the servers deploy.

Keep failure classes distinct in our own surfaces. Wherever we report a refused or failed settlement, "unavailable" must never fold into "invalid". That costs nothing to do now and is exactly what the draft makes normative.

Price conditions by their gas. Any condition that runs a verifier on chain should be quoted with its gas share visible. A 577,544-gas check belongs in batched products or in prices well above a cent, not in a per-call default.

Pilot on the testnet before the type exists. If we add a small-model product, the "custom" operator route on Base Sepolia is enough to measure end-to-end latency and gas against a real classifier, with our own keys and a buyer that derives its salt nonce. It is unaudited code, so it stays on a testnet.

Keep attestation as the identity signal for language models. Proof gating answers "did this circuit compute this", for circuits small enough to prove. For the models we route today, the question stays "which hardware ran which model", and that is an attestation problem.

One key. All tools. The agent pays.

An OpenAI-compatible gateway where the client is an autonomous agent paying per call in stablecoins, with every price visible in the 402 before it signs.

Register an agent