← Blog
November 5, 2026 · 11 min

x402 upto on XRPL: The Escrow Rewrite, Tested on Testnet

x402's upto scheme lets a buyer authorize a ceiling and pay the measured amount. On the XRP Ledger the natural primitive is a payment channel. An open spec PR now rewrites the flow so the buyer signs the channel but never submits it. We ran that design on XRPL testnet to see where the ledger bends the spec.

The happy path works exactly as written. Four edge cases do not behave the way a reader of the spec would assume. Two of them matter for an agent that makes many calls from one account.

Sources: PR #4008 (head a1f02ff, open, no reviews, 27 October 2026), the scheme_upto_xrpl.md on that head, issue #3950, and our own runs on 5 November 2026 with xrpl.js 4.7.0 against the public testnet (rippled 3.4.1) and mainnet read-only endpoints.

What the spec changes

The XRPL upto profile (#3023, merged 22 October) declared the authorization flow. The client opened and funded a PayChannel itself, signed an off-ledger claim over (channelId, maxAmount), and only then sent PAYMENT-SIGNATURE. Facilitator /verify read the channel from the ledger.

Issue #3950 (26 October) pointed out the flaw. Funds are locked on-chain before the handler runs, but nothing on the wire says so. One channel can pass /verify for two concurrent requests and only one can settle. A failed handler leaves the maximum locked until SettleDelay or CancelAfter.

PR #4008 answers with the escrow flow, the same one SVM upto uses. The steps are:

  1. The client signs a PaymentChannelCreate offline and derives channelId = SHA512Half(0x0078, Account, Destination, Sequence).
  2. The client signs the off-ledger claim for the maximum and sends both, the create as payload.openTransaction.
  3. The server calls /settle with payload.type = "deposit". The facilitator decodes every field, rejects an existing channel, dedupes on (network, channelId), submits, waits for validation and re-reads the channel.
  4. The server runs the metered work.
  5. The server signs a PaymentChannelClaim with tfClose for the actual amount and calls /settle with type = "claim". The facilitator holds no key.

It also adds extra.destinationTag, a mandatory LastLedgerSequence cap on the signed create, settlement_pending for ambiguous submits, and a client recovery section. Our earlier post on upto and Permit2 covers the generic scheme this profile plugs into.

One detail to note. Issue #3950 asked for the SVM wire names (payload.from, extra.withdrawDelay, payload.claimTransaction, no publicKey). The PR keeps payload.payer, extra.minSettleDelay, payload.settlementTransaction and payload.publicKey. Only type and openTransaction were aligned. A client library that already speaks SVM upto cannot reuse its payload builder as is.

The test harness

We wrote three short scripts. Each funds two testnet accounts, plays the buyer (signs offline, submits nothing itself unless stated) and the server (signs the claim), and uses the ledger as the facilitator would. We checked results through account_info balances and ledger_entry.

CaseResult on testnet
Deposit, then claim Balance 3 XRP, Amount 10 XRP, tfClosetesSUCCESS. Server +2,999,988 drops (3 XRP minus the 12 drop fee). Payer +7,000,000 refund. Channel deleted.
Zero settlement: bare close, no Balance/Amount/SignaturetesSUCCESS. Payer +10,000,000 refund.
Second close against the closed channel (fresh blob)tecNO_TARGET, as the spec says.
Create signed at sequence N, payment at N+1 sent firstPayment returns terPRE_SEQ and the account sequence stays at N.
Create signed with a ticketOther payments from the account apply at once. Channel id derives from the ticket number.
Resubmit the identical create or close after it validatedtefPAST_SEQ.
Claim for 3 XRP on a channel past CancelAftertesSUCCESS, delivered 0, payer refunded 10,000,000.

The first three rows confirm the design. The claim shape the spec prescribes is the right one. Amount carries the signed maximum, Balance the actual charge, and a zero charge is a bare close that refunds everything. The rest of this post is about the other four.

Finding 1: an unsubmitted create holds the account

The spec says the payer MAY send other transactions before the deposit settle "only when they do not consume that sequence". That is true and it hides the cost.

XRPL applies an account's transactions in sequence order. We signed a create at sequence N, did not submit it, and sent a payment at N+1. The node answered terPRE_SEQ ("missing or inapplicable prior transaction"). Nine seconds later the account sequence was still N. When we finally submitted the create, both landed in order. The N+1 payment had been held by the node.

For a single request this is a small delay. For an agent it is a queue. Picture eight concurrent paid calls from one account. Each needs its own signed create at N, N+1, and so on up to N+7. If the request holding N is abandoned, none of the later creates can land until N is consumed or its LastLedgerSequence passes. Everything else the account tries to send waits behind them too.

Tickets remove the problem, and they work with the scheme. We created a ticket, signed a PaymentChannelCreate with Sequence: 0 and TicketSequence: T, and left it unsubmitted. A normal payment from the same account applied immediately. The create then landed, and the channel id on the ledger matched SHA512Half(0x0078, Account, Destination, T), the ticket number, not the account sequence.

The spec text says the signed create "fixes the sequence used in channelId". It does not say that a ticket number is the sequence in that formula, nor that Sequence = 0 is allowed. A facilitator that recomputes the id from the blob's Sequence field will compute the wrong id for a ticketed create and reject it as invalid_upto_xrpl_open_transaction_mismatch. The spec should state the ticket rule.

Finding 2: tesSUCCESS that delivers nothing

The spec warns that a claim applied to an expired channel closes it without delivering and still returns tesSUCCESS. We reproduced it. The channel was created with CancelAfter 20 seconds out. After 35 seconds the server submitted a claim for 3 XRP, correctly signed. The result was tesSUCCESS. The server balance moved by minus 12 drops, the fee. The payer got the full 10 XRP back. The metadata has no delivered_amount, and the deleted PayChannel node shows a final Balance of 0.

So a facilitator that reads the result code and reports success: true has told the server it was paid when it was not. The spec says a facilitator SHOULD confirm the delivered amount from metadata. We would make it MUST, and say how: compare the deleted channel's final Balance with the balance before the claim. The claim's own Balance field is the request, not the outcome.

This is the same class of gap we found in settlement finality: a success flag with no depth behind it. On XRPL it can also be a success with no payment.

Finding 3: retries and the settlement_pending gap

The duplicate-settlement section says a retry layer resubmitting an identical signed blob "would report tesSUCCESS twice". We could not reproduce that after validation. Resubmitting the identical create, and the identical close, returned tefPAST_SEQ both times. The double-success case may exist inside one open-ledger window. We did not test that window, so we leave the claim open.

The practical point is different. tefPAST_SEQ is what a facilitator sees when a retry follows a submit that did land. It is also what it sees when the payer consumed that sequence with some other transaction. The two cases look the same until you fetch the transaction by hash. The spec's rule to release the dedupe entry on a "final result in a validated ledger that is not tesSUCCESS" does not cover a tef code that was never in a ledger.

The larger gap is the deposit settle that returns settlement_pending. The broadcast hash is known, the channel may now exist, and the spec says to reconcile on ledger before retrying. But a retry of the deposit settle hits two rules. The entry is retained after an ambiguous outcome (duplicate_settlement), and an existing channel is rejected (invalid_upto_xrpl_channel_already_open). Neither is wrong, but nothing says what the server does next.

The sensible path exists. Look up the create by hash, confirm the channel, serve the request, and go straight to the claim settle, which only needs the channel to exist. The 412 CHANNEL_REQUIRED text even hints at it ("no open channel and no valid openTransaction"). It should be written as a step. The same state arises when a buyer submits its own copy of the signed create first. Nothing stops that, and the buyer ends up with a funded channel and an error response.

Finding 4: the ten-second ledger

The time-bounds rule sets a landing margin of 20 seconds, "two 10-second ledger closes", and derives openLedgerWindow as at least ceil((maxTimeoutSeconds + 20) / 10) ledgers. We measured mainnet over the last 1,000 validated ledgers on 5 November. They took 3,980 seconds, an average close of 3.98 seconds.

With the spec's own example of maxTimeoutSeconds = 300, the floor is 32 ledgers. At the real rate that is about 127 seconds of validity for the signed create, less than half the timeout it is meant to cover. A facilitator that uses exactly the floor rejects a create whose LastLedgerSequence reaches further out, so a signed create is useful for about two minutes at most.

The constant errs on the safe side where it sizes the dedupe retention, since a slower assumed close means keeping the entry longer. It errs on the unsafe side where it sizes a minimum window. The two uses need different numbers. For reference, xrpl.js 4.7.0 autofill adds 20 ledgers, about 80 seconds, to LastLedgerSequence.

Two numbers did check out. The mainnet owner reserve increment is 0.2 XRP, as the spec says, with a 1 XRP base reserve. And the pre-signed fee is not a problem today: six samples of the fee call showed an open-ledger fee of 10 drops with 213 to 282 transactions against an expected size of 500. A create signed offline with a fixed fee would fail only if the open-ledger fee escalated between signing and the deposit settle.

Two traps for implementers

We hit both in the harness, and both fail without a clear message.

What it means for LLM4Agents

XRPL is one of the fifteen settlement bindings we mapped in the network bindings audit, and upto is the scheme that fits metered LLM calls best, because the final token count is unknown when the buyer signs. The escrow design is the right one for us. The seller sees funds locked before it spends compute, and the buyer's exposure is a fixed ceiling with a bare-close refund on failure.

But the failure modes above map directly onto an agent fleet. A fleet makes parallel calls. Sequence-held creates would serialize an account, and a success that delivered nothing would, in our gateway, release a response that was never paid for. We reserve before we proxy and settle after, so a false settle success is a direct loss. That is the same reason we described in the two-phase gap.

These notes are what we would require before adding XRPL as a rail.

Staying on the frontier

  1. Comment on PR #4008 with the ticket rule. Ask that the spec state that TicketSequence is the sequence in the channel id formula and that Sequence = 0 is accepted. Include the testnet result.
  2. Ask for MUST on delivered-amount confirmation. Cite the expired-channel case: tesSUCCESS, delivered 0. Our rule is simple. A settle is successful only if the channel's final balance rose by the charged amount.
  3. Specify the settlement_pending recovery. Request an explicit "adopt existing channel" step: look up by hash, serve, claim.
  4. Run the harness on every spec head. It is three short scripts and runs in a few minutes. Rerun it when the PR merges or the wire names change.
  5. Plan for tickets in any XRPL buyer we ship. One ticket per concurrent call, replenished in batches. Never let two requests share a sequence.
  6. Measure close time from the ledger, not a constant. If we implement a facilitator check, derive the window from recent validated ledgers with a floor.
  7. Hold the XRPL rail behind a flag until the PR merges. The wire names may still move to the SVM ones. Watch #4008 and #3950, and compare with the Stellar window audit for how another ledger with pre-signed artifacts handles the same gap.

Pay per call, in stablecoins, from any agent

Register an agent on LLM4Agents and pay per request over an OpenAI-compatible gateway.

Register agent