← Blog
November 15, 2026 · 15 min

x402 numbers past 2^53: Go rounds them, matchers can't see them

JSON puts no limit on the size of a number. The parsers that read x402 messages do. Above 253, a JavaScript number or a Go float64 can no longer hold every integer, and the value changes without an error.

On 2026-11-13, issue #4258 reported that the Go SDK at v2.31.0 rounds 9007199254740993 to 9007199254740992 inside payment payloads, even when the caller asks for exact numbers. Within 24 hours two pull requests offered the same fix: #4269 and #4270. Both still wait for a required review.

We did not stop at the reproduction. We ran probes against five Go trees (the last release before the regression, main, both PR heads, and a decoder-only variant we built ourselves), against @x402/core 2.31.0 in TypeScript, and against the x402 2.28.0 package in Python. We also scanned the spec's examples and the public Bazaar catalog for numbers that could actually hit the line. Today's standard schemes stay clear of it. The Go facilitator client has rounded since the v2 rewrite, the server matchers in two of three SDKs cannot see the rounding, and a JavaScript buyer cannot pay a Python seller that puts a large integer in extra.

Where 2^53 sits in payment terms

253 is 9,007,199,254,740,992. Every integer up to that value fits exactly in an IEEE-754 double. Past it, the gap between neighbouring doubles is 2, then 4, then larger, so odd integers start to vanish.

Whether that matters depends on the unit. In USDC atomic units, with 6 decimals, the line sits at about 9.007 billion dollars. No payment gets near it. For an 18-decimal token, it sits at about 0.009 tokens, so almost any real balance crosses it. The line also falls inside the u64 range that Solana uses for lamports and slots, and far inside the uint256 range of EVM nonces.

x402 sidesteps most of this by writing amounts as decimal strings. The exact EVM scheme sends value, validAfter, validBefore and nonce as strings. Its Permit2 example carries a 77-digit nonce, "33247007178036348590600198031289925668252061821958005840077069883511451257277". Had that been a JSON number, JSON.parse would have turned it into 33247007178036348484650333814013637535634973362439186252067479837571939303424, a different nonce from the one the client signed.

The strings stop at the core fields. extra, payload and extensions are open maps, and schemes put numbers in them. We parsed the 196 JSON code blocks in specs/ that are valid JSON and listed every numeric field. The list includes withdrawDelay, recentSlot, openSlot, expiresAt, captureDeadline, refundDeadline, minFeeBps and maxFeeBps. None of the values in those examples is above 253.

Only one normative sentence in the specs names the boundary. The EVM batch-settlement scheme requires a voucher manager to parse totalClaimed as either a plain decimal string or "a JSON number that is a non-negative integer no greater than 2^53 − 1". Anything else counts as missing. No other field gets that rule, and the core spec says nothing about numbers in open maps.

What issue #4258 found

The reporter, nkavian, gave a short reproduction. It decodes a PaymentPayload through a json.Decoder with UseNumber(), then marshals it again. payload.counter comes back as float64, and the output reads 9007199254740992. The string amount is unchanged.

The cause is three custom UnmarshalJSON methods in go/types/v2.go, on PaymentRequirements, PaymentPayload and PaymentRequired. They arrived with #3884, merged on 2026-10-26, which rejects V2 networks that are not CAIP-2 identifiers. Each method calls json.Unmarshal internally. As contributor Mramaran put it in the thread, Go never passes a decoder's UseNumber() setting into a custom UnmarshalJSON. Six maps are affected: the payload, its extensions, its accepted.extra, the 402's extensions, each accepts[].extra, and a standalone requirement's extra.

We checked the release history. go/v2.28.0, tagged on 2026-09-29, has no custom decoders. go/v2.29.0, tagged on 2026-10-28, is the first release with them, and v2.31.0 (2026-11-12) still has them. Our probe confirms the line:

// decode with the caller's UseNumber(), then json.Marshal again
go/v2.28.0     payload.counter = json.Number  re-encoded 9007199254740993
main, v2.31.0  payload.counter = float64      re-encoded 9007199254740992
PR #4269       payload.counter = json.Number  re-encoded 9007199254740993
PR #4270       payload.counter = json.Number  re-encoded 9007199254740993
// same result for accepted.extra.k and extensions.e.v; "amount" stays "9007199254740993" everywhere

One nuance matters. The Go SDK never calls UseNumber() itself; we found no call to it outside tests on main. A program that decodes with plain json.Unmarshal got float64 before #3884 as well. The regression only hit callers who had opted into exact numbers. Both fixes go further and make exact decoding the default for these maps, so they change behaviour for every caller.

The older leak: the facilitator client

Fixing the decoders leaves a second, older copy of the rounding. A Go resource server that uses HTTPFacilitatorClient hands it the payload and requirements as bytes. Before posting to /verify or /settle, verifyHTTP and settleHTTP decode both documents into map[string]interface{} and marshal them again. That round trip goes through float64.

Blame puts that line in #705, the v2 development merge of 2025-12-11. It is not part of the regression. We pointed the client at a local test server and captured the body it posted:

// HTTPFacilitatorClient.Verify(payload with "counter":9007199254740993)
go/v2.28.0    body sent to /verify: "counter":9007199254740992
main          body sent to /verify: "counter":9007199254740992
PR #4269      body sent to /verify: "counter":9007199254740993
PR #4270      body sent to /verify: "counter":9007199254740993

So for the life of the v2 Go SDK, a facilitator behind a Go server has seen a different document from the one the client sent whenever a number in it was past the line. #4269 fixes this by decoding into map[string]json.RawMessage, which forwards the original text. #4270 added the same fix in its latest head, 867d8c3, after reviewer erkancamli flagged the gap on 2026-11-15.

Two PRs, one decoder, different reach

Both PRs change the three decoders the same way: decode with UseNumber(), keep the CAIP-2 check. The difference is everything that reads those maps afterwards. A Go helper that type-switches on case float64: and falls through to a default stops seeing its value once the type becomes json.Number. Nothing errors. The helper just behaves as if the field were absent.

We built a decoder-only tree to show what that costs: main plus #4270's go/types/v2.go and nothing else. Then we ran the EVM batch-settlement facilitator's ValidateChannelConfig on a seller that requires withdrawDelay: 86400 and a channel opened with the 900-second minimum:

// requirements decoded from JSON; extra.withdrawDelay = 86400, channel = 900
main          float64      -> invalid_batch_settlement_evm_withdraw_delay_mismatch
decoder-only  json.Number  -> <nil>   // check skipped
PR #4269      json.Number  -> invalid_batch_settlement_evm_withdraw_delay_mismatch
PR #4270      json.Number  -> invalid_batch_settlement_evm_withdraw_delay_mismatch

The guard reads if expectedDelay != 0 && ..., and an unrecognised type leaves expectedDelay at zero. A fix that touched only the decoders would turn that check off. A seller who asked for a one-day withdrawal delay would accept a channel where the payer can finalize a withdrawal 15 minutes after requesting it, which shrinks the window the seller has to claim its vouchers. Both PRs patch this reader. That is why the reader sweep matters as much as the decoder change.

The two sweeps differ in size. #4269 touches 11 files (+455/−37) and its Go, Python and TypeScript CI jobs pass. #4270 touches 31 files (+783/−86). So far its checks show only the labeler and the verified-commit job; no test job appears. To compare the sweeps, we copied #4270's 13 new test files onto #4269's tree. The types and http tests pass there. Sixteen tests fail across nine packages: auth-capture, the EVM batch-settlement facilitator and server, and six SVM packages.

Most failures fall into two classes that erkancamli reported in public reviews of both PRs on 2026-11-15. First, integral decimals. Under float64, a withdrawDelay of 60.0 or 6e1 was just 60. As json.Number, helpers that only try Int64() reject it. The reviewer's example is an auth-capture captureDeadline of 1900000000.0: accepted on main, rejected on #4269. A Python server writes exactly that text when its value is a float, because json.dumps(60.0) prints 60.0. Second, several of #4269's new json.Number branches convert through Float64(), so u64 readers lose the top of their range. Its ParseExtraUint64 returns (0, false) for 18446744073709551615.

The rest include readers #4269 did not touch, such as the EVM batch-settlement server's channel-state readers. Those read facilitator responses, which both PRs still decode with plain json.Unmarshal, so they are not reachable through the new decoders today. #4270 converts them anyway. We did not trace every caller.

One more edge exists on main and both PR heads. Auth-capture's JSONNumberToUint64 accepts float64(2^64) and returns 9223372036854775808 with ok = true, because its range check uses > and Go's conversion of an out-of-range float is implementation-defined. On main, a requirement with captureDeadline: 18446744073709551616 reaches that path: ParseAuthCaptureExtra returns a deadline of 9223372036854775808 and no error. On both PR heads, the same requirement is rejected, and only in-process callers can still reach the float branch.

The matcher cannot see the difference

Neither PR touches the check that binds a client's choice to the server's terms. In Go, FindMatchingRequirements compares the core fields and then requires the server's extra to be a subset of the client's accepted.extra. Primitive values go through a helper called DeepEqual. It marshals both sides, unmarshals them into interface{}, and compares the re-marshalled text. That middle step produces float64 again.

We gave a Go server an extra.k of 9007199254740993 and a client that echoed 9007199254740992. On v2.28.0, main, #4269 and #4270, the requirement matched. So did a server value of 18446744073709551615 (u64 max) against an echoed 18446744073709551616, which no u64 can hold. A value of 60 against 61 failed, as it should. The binding check is blind past 253 on every Go tree, including both fixes. Whatever catches a mismatch there has to sit downstream, in the scheme or the facilitator.

We have seen this layer give way before. In our audit of the facilitator's asset checks, the server-side match was the only thing standing between a listed token and any EIP-3009 contract. Here the match holds for equal-looking numbers that are not equal.

Three SDKs, three number models

Go is not alone. Each SDK inherits its language's number model, and the three models disagree. We ran the same cases through all three:

// server extra.k vs client-echoed accepted.extra.k -> requirement matched?
                          Go (all 4 trees)  TS @x402/core 2.31.0  Py x402 2.28.0
2^53+1 vs 2^53            match             match                 no match
u64 max vs 2^64           match             match                 no match
60 vs 60.0                match             match                 match
1 vs true                 no match          no match              match
decode 2^53+1, re-encode  rounded (main)    rounded               exact
                          exact (PRs)

TypeScript has no choice. decodePaymentSignatureHeader runs JSON.parse, and a JavaScript number cannot represent 9007199254740993. The value is rounded on arrival, so the TypeScript matcher compares two copies of the same rounded number. A TypeScript server cannot even author the original value in its own config.

Python is the only exact one. json.loads and the pydantic models in the x402 package return integers as Python int, which has arbitrary precision. model_dump_json writes all four test values back unchanged. #4269's description says TypeScript and Python "parse these maps with JSON.parse and json.loads" and that "those parsers use IEEE-754 floats". That holds for TypeScript, and for Python floats. For Python integers it does not hold.

Python has its own quirks. Its matcher compares with ==, and in Python True == 1, so a client that echoes true for a server's 1 matches. The Go and TypeScript matchers reject that. The Python facilitator client also has a helper, _to_json_safe, whose docstring says it "handles bigints". It passes a lambda as json.dumps(default=...) to turn integers above 253 into strings. json.dumps only calls default for objects it cannot serialize, and integers are not among them, so the lambda never runs. We confirmed it: 2**60 goes out as an exact number. The helper has been a no-op since the Python SDK's v2 rewrite in #841 (2026-01-21). That is lucky: had it worked, it would have changed numbers into strings inside signed documents.

Put the models together and a cross-SDK failure follows. Suppose a Python seller puts a large integer in extra. A TypeScript buyer decodes the 402, rounds the value and echoes the rounded number in accepted. The Python matcher compares exact integers, finds no match, and answers 402 again. The buyer can never pay. Every released v2 Go buyer does the same, because the SDK's own decoding has always produced float64. After either fix lands, a Go buyer will echo the exact value and pay. The TypeScript buyer still cannot. We did not run these pairs end to end; the outcome follows from the decode and match results above. This is the same kind of split we found when three SDK parsers disagreed on ERC-6492 wrappers: one spec, three readings, decided by the language rather than the protocol.

How much of this is live

The spec examples stay clear of the line. To see what sellers actually publish, we paged through the full CDP Bazaar discovery catalog on 2026-11-15 and parsed it with Python, which keeps integers exact. The catalog held 33,847 entries: 33,827 unique resources on 3,194 hosts, with 82,177 payment options between them. Every amount was a string. 9,347 resources put at least one number in accepts[].extra, and 5,394 put one in an extension other than Bazaar. The most frequent were eip712Domain.chainId (5,583 occurrences), sourceTag (3,235) and the length limits of the builder-code and payment-identifier extensions. withdrawDelay appeared 396 times, and 779 numbers in extra were fractional. In those payment-facing maps we found no integer above 253 − 1.

The large numbers live in discovery metadata. The Bazaar extension's input schemas and output examples hold 316,486 numbers, and 37 of them, on 14 hosts, are past the line. Of the 33 that are integers, 22 carry the fingerprint of a trip through a double: their digits are the shortest decimal form of a float64, not a plausible original. One host's nanosecond timestamps end in ...6100; 1605192959994246100 is how JavaScript prints the double 1605192959994246144. A media ID reads 2066778128366940200. A JSON Schema maximum of 9223372036854776000 appears nine times on two hosts. That is int64 max after one round trip, and it is now 193 larger than int64 max itself.

We cannot tell whether the rounding happened in the sellers' serializers or in the catalog's ingestion. Either way, none of it is payment terms. It does show what the failure looks like when it happens: no error, plausible digits, and a schema bound that now admits 193 values no int64 can hold. The protocol is clean today because schemes chose strings, not because any layer would notice a number going wrong.

What it means for LLM4Agents

We probed our own 402 first. An unauthenticated POST /v1/chat/completions returns one requirement on Base. Its only numbers are x402Version (2) and maxTimeoutSeconds (300). amount is the string "10000", and extra holds only the EIP-712 name and version strings. On the payment side, every field of the exact EVM payload we verify is a string. Nothing we quote or verify today sits near 253.

That is a property of what we publish, not of how we parse. Our resource server runs the TypeScript SDK, so a number past the line in an incoming payment header would be rounded on arrival, silently, and our matcher would compare the rounded copy. A Go client built on either fix would then send bytes that our server does not read back the same way. For the exact scheme, that is harmless, because nothing signed is a number. For the schemes we have looked at for metered inference, it is not automatically harmless.

Batch settlement and auth-capture carry their numbers in extra and the payload: withdrawal delays, deadlines, fee basis points, and in batch settlement the channel's balance and totalClaimed. The small ones are safe in any language. The balances are safe in USDC. If we ever settle an 18-decimal asset through those paths, any balance written as a JSON number would cross the line above 0.009 tokens. The only spec rule covering it, for totalClaimed, treats such a value as missing.

Staying on the frontier

The steps, in order. First, write the rule down and test it. Every integer we emit that is an amount, a balance, a nonce, an identifier or a sub-second timestamp goes out as a decimal string. Numbers stay only for small counts and durations. A unit test on our 402 builder will walk accepts and extensions and fail on any number that is not a safe integer or a short decimal. That costs one test and closes the door on our side.

Second, refuse instead of rounding at ingress. Node 22 passes the original source text to a JSON.parse reviver; we confirmed that on v22.22.2, where the reviver sees "9007199254740993" for a number the parser itself rounds. A reviver on the payment header can reject any integer literal outside the safe range with a clear 402 reason. A payment that would have been verified on rounded data then fails loudly, before a facilitator sees it.

Third, contribute what the thread is missing. A shared test vector, a payload with 2^53+1 in extra, payload and extensions, would force each SDK to either round-trip it exactly or reject it, never round. The matcher's DeepEqual normalisation is untouched by both PRs and worth one review comment on #4258. So is the Python helper that never fires. The spec's totalClaimed sentence is a template for a general rule: integers that can exceed 253 − 1 travel as strings.

Fourth, track the fix. When #4269 or #4270 merges and a new go/v2 tag ships, re-run these probes against it. Any Go tooling we build, such as test buyers and facilitator harnesses, should pin that version or later. Fifth, keep the scope narrow. We will not swap in a lossless JSON parser across the gateway. The risk lives in payment headers and settlement records, and that is where the guard belongs.

Payment terms that survive every parser.

LLM4Agents is an OpenAI-compatible gateway where autonomous agents pay per call in stablecoins over x402, with amounts that travel as strings and quotes from $0.01.

Register an agent