← Blog
November 11, 2026 · 14 min

x402 upto on Casper: a zero charge never spends the nonce, and the contracts are not public yet

The x402 upto scheme lets a buyer sign a ceiling and a seller charge less. An open pull request specifies it on Casper, using a port of Uniswap's Permit2. We recomputed the spec's cryptographic test vector and it holds. What it does not settle is more interesting: a zero charge leaves the signed authorization alive, and the contracts it depends on cannot be fetched.

We have now covered upto on three rails. The original EVM design uses Permit2. The EIP-3009 proxy proposal pulls the full ceiling and refunds the rest. The XRPL profile uses escrow and payment channels. Casper is the fourth, and it is a straight port of the EVM Permit2 design with a few changes that matter. Everything below comes from the spec text at the commit named, from our own recomputation, and from probes of public URLs dated today.

What is on the table

PR #4158 on x402-foundation/x402 was opened 2026-11-05 by an outside contributor. Its head is 521582d. It adds one file, specs/schemes/upto/scheme_upto_casper.md, 524 lines, no deletions. As of 2026-11-11 it has no reviews and one comment, from the Vercel bot saying a Coinbase team member must authorize a deploy. Main was at 8b5b0cd.

The description says this is "PR 1" of the repository's new-chain workflow: spec only, SDK later. It also says the contributor used Claude Code to write the spec, as the contribution guidelines ask. Casper exact is already in: #2741 merged 2026-07-08, and @x402/casper 2.30.0 (npm, 2026-11-04) ships the exact scheme. We unpacked the package source in the repository and found no upto code and no Permit2 reference. So nothing here can be used today.

The mechanism

Casper exact uses CEP-3009, a port of EIP-3009 for CEP-18 tokens. As on EVM, it commits to a fixed value and cannot settle less. So upto takes the same route as the EVM scheme: Permit2 plus a proxy.

PieceJob
CEP-18 tokenBuyer approves the Permit2 package once, usually for the maximum value.
Permit2 for CasperChecks the buyer's signature, burns the nonce, enforces the deadline and that the amount is at most the signed ceiling, then calls transfer_from.
x402UptoPermit2ProxyThe signed spender. Rebuilds the witness, requires the caller to be the bound facilitator, requires validAfter to have passed.

The buyer signs a PermitWitnessTransferFrom message: token, ceiling, spender (the proxy), nonce, deadline, and a witness of (to, facilitator, validAfter). The facilitator chooses only the amount, bounded by the ceiling. That is the same shape as the EVM profile. Two Casper details differ. Addresses are 33 bytes, a tag (00 account, 01 contract package) and a 32-byte hash, and in the signed message each becomes keccak256(tag ‖ hash) so an account and a contract with the same bytes never collide. And the signature is checked by the contract against a separately passed public key, so the payer is always an account, never a contract.

What we reproduced

The spec publishes a golden vector "computed with an independent EIP-712 encoder": a domain, three type hashes, a witness hash, a struct hash and a digest, over fixed inputs. A vector nobody re-derives is decoration. We re-derived it from the spec's own encoding rules with viem 2.x keccak256, nothing else.

# recompute from the spec's type strings and encoding rules, 2026-11-11
EIP712Domain type hash        e20dd139...64fad4fb   # spec: same
TokenPermissions type hash    618358ac...9846d06a1  # spec: same
Witness type hash             d4171c44...a2253b75   # spec: same
PermitWitnessTransferFrom     51dff697...1d70c2ee   # spec: same
witness hash                  6790d321...bdf5f420   # spec: same
struct hash                   f5cad14e...424ed09c   # spec: same
digest                        b6bad959...03ff48bd   # spec: same
domain separator              e1f1655a...e4286f055  # not published in the spec

All seven published values match. The spec's Witness type string, "Witness witness)TokenPermissions(...)Witness(...)", also concatenates correctly after Uniswap's prefix into the full type string that hashes to the published value. That is a real result: an implementer following the text will get the same digest as the author.

The limit matters. This proves the document is internally consistent. It does not prove any contract computes the same digest, because we could not look at the contracts. That is the next section.

The contracts are not public

The spec depends on "Permit2 for Casper" and on the proxy. Its test section says the spec "was checked against the Permit2 for Casper and x402UptoPermit2Proxy Odra contracts and their tests." Its external references list github.com/casper-ecosystem/permit2 as "the contract this scheme depends on."

On 2026-11-11 that URL returns HTTP 404, and so does the same repository through the GitHub API. The casper-ecosystem organization's repository list has cep18, casper-eip-712 and others, but no permit2. A private repository would look the same from outside, so we do not claim it does not exist. We claim a reviewer cannot read it.

Three consequences follow.

The spec also requires both packages to be deployed locked, and asks facilitators to check at startup that they are locked, that the proxy points at the canonical Permit2, and that Permit2's chain_name() equals the network. That is a good operational rule. It cannot be followed until there are addresses to check.

A zero charge never spends the nonce

This is the design point worth the most attention.

On the EVM profile, a zero settlement means no transaction and the authorization "simply expires unused." The Casper spec says the same, then adds what that implies. A Permit2 nonce is only consumed when a transfer happens. With a zero charge, nothing happens on chain, so the buyer's signed authorization is still fully valid until its deadline. The spec's own example has a window of 3,660 seconds, from validAfter 1793798547 to deadline 1793802207.

So the spec adds a rule the EVM text does not have. Facilitators MUST track each authorization by (network, from, nonce). A zero settlement is tracked and kept "until deadline has passed", and the facilitator MUST NOT settle it later. A second request gets duplicate_settlement.

Read what that makes the facilitator's memory: the only guard. The chain does not know the authorization was closed. The signed message is spendable by the bound facilitator account, and the resource server tells the facilitator the amount in each settle call. Three failure paths open:

None of these needs a broken contract. Each needs a tracker that is not durable. The spec states the MUST but not where the state lives, and it does not tie the tracker's lifetime to anything that survives a process restart.

The buyer has an exit. Permit2's invalidate_unordered_nonces closes an unused authorization on chain. It costs the buyer gas in CSPR, so an agent will not do it for every free call.

This matters more for metering than for fixed prices. In LLM billing, zero is common: a request rejected on validation, a call that times out before any token. A rail where each of those leaves a live, signed spend ticket is a rail where the seller's bookkeeping is part of the buyer's security.

The concurrent settle costs the facilitator gas

The spec is candid about a second hazard. Two simultaneous settle calls with the same payload build two different Casper transactions with different hashes. The node accepts both. The second reverts with NonceAlreadyUsed (38003), and the facilitator pays its gas. A reverted settlement must be returned as success: false with the transaction hash, so the failed cost is visible to the caller.

The remedy is the same tracker. It has to be written before the submit and cleared only when the result is known or the deadline passes. That makes the facilitator stateful per authorization. We made the same point about the two-phase gap: the gap between verify and settle is where free riding and double spend live, and here it also costs the party that submits.

The buyer needs CSPR, once

Permit2 pulls with transfer_from, so the buyer must first call token.approve(Permit2, amount). The spec says buyers "usually" approve the maximum, that CEP-18 tokens decrement even a maximum allowance on each transfer, and that the buyer pays gas for this transaction and "therefore needs CSPR once." We took the decrement claim from the spec; we did not test it.

The EVM profile offers two ways out: erc20ApprovalGasSponsoring and eip2612GasSponsoring, where the facilitator pays for or batches the approval. The Casper spec says "This specification defines no sponsored approval." A missing allowance returns HTTP 412 with permit2_allowance_required, the same convention as EVM.

For an autonomous agent this is an onboarding wall. A fresh wallet funded with csprUSD, the default asset in @x402/casper at six decimals, cannot make its first upto payment until someone gives it CSPR for gas. The spec's own error table lists a CEP-2612 range (36000+), which suggests a permit standard exists on Casper, but the spec does not use it. We can only say it is not defined here.

One advantage over last week's design is worth noting. The EIP-3009 proxy had to receive the full ceiling at settlement. Here the transfer is only for the metered amount. The spec lets a facilitator check balance and allowance against the settlement amount instead of the ceiling. A buyer can sign a ceiling larger than their balance, and a small real charge still works.

The key model is narrower than an account

The Security Considerations section holds two warnings an agent builder should read.

Both are consequences of how the check is written, not bugs. They do mean there is no scoped or delegated signer in this scheme. An agent wallet holds the one key that can sign, and the one allowance that makes it spendable.

The first Security point is the same one we make about every upto rail: the maximum, recipient and single use are enforced on chain, and the metered amount is not. The buyer trusts the server's meter inside the ceiling.

What it means for LLM4Agents

Casper is not a chain we settle on. This is not a feature request. It is a worked example of what a metered rail asks of the party that runs the gateway.

Our billing today is reserve, proxy, settle: we quote a ceiling in the 402, run the model, then settle the real cost. That is the upto shape, implemented in our own accounting. Any rail that makes it native has to answer the questions this spec answers: what happens to the authorization when the real cost is zero, who remembers that, and what the buyer must hold before the first call.

The zero-charge case is the one to take home. Our gateway returns errors and timeouts that cost the buyer nothing. On a Permit2-style rail each is a signed ticket that stays valid. If we ever settle on such a rail, our tracker must be durable, shared across instances, and keyed by the authorization identity, before the first payload is accepted. A free-call log in memory is not enough.

It also confirms the order of risks we have seen across upto rails. The cryptography is the easy part and reproduces. The hard parts are state that lives off chain, gas for a first approval, and whether the contracts can be read.

Staying on the frontier

First, keep upto status current across rails. Four profiles now exist as specs: EVM Permit2 (with a deployed proxy address in its spec), EVM EIP-3009, XRPL and Casper, the last three being open pull requests when we last read them. Only the first names a deployed contract. Do not offer a metered rail we cannot test.

Second, watch #4158 for three events: a first review, a public contracts repository with package hashes, and an SDK PR. Until the contracts are readable, re-run our digest recomputation only against numbers that come with addresses. When they appear, compare the contract's digest to the spec's vector and diff the proxy's rules against the MUST list.

Third, write our own zero-settlement test before we need it. Build a harness with a fake facilitator that restarts between the zero report and a replay, and assert the replay is refused. Any metered rail we adopt should pass it.

Fourth, treat the gas-for-approval question as an onboarding requirement. For each future rail, record whether a buyer with only stablecoin can pay, and whether approval can be sponsored. EVM can. Casper, as specified, cannot.

Fifth, add key-rotation guidance to our agent-wallet docs. On any rail where the old key stays valid, a compromise needs a revoke on every token, not only a new key.

Sixth, keep the recomputation script. It is under forty lines and takes two seconds. A published test vector is a cheap thing to verify and an expensive thing to get wrong.

Pay per call, in stablecoins, over an OpenAI-compatible API

One 402, one signature, 345+ models. No subscription, no minimum.

Register your agent