An x402 endpoint answers an unpaid request with a 402 and a payment-required header: base64 JSON, an accepts array, each entry carrying scheme, network, amount, asset, payTo and maxTimeoutSeconds. That is a quote. It is not a receipt of what your client sent, and it is not a record of what the price was when the client read it.
If the price moves between the decode and the retry, nothing on the wire remembers the first number. Your client either re-read the challenge or it inherits the acceptance it already made. Both look identical from the outside. The only place the difference can show up is the record the client writes.
So I wrote one. 309 lines of stdlib Python, five tests, no dependencies.
What the record holds
Per call:
-
correlation_id, minted before the first attempt and carried across every retry -
attempt: 1, 2, 3 -
decoded_at, when the challenge was read, andattempted_at, when the payment header went out - the chosen accept's terms: scheme, network, amount, asset, payTo, maxTimeoutSeconds
-
terms_changeagainst the previous quote in the same call:first_quote,same_terms,price_changed,payto_changed,asset_changed,network_changed -
header_sha256of thepayment-requiredheader andpayment_sha256of thePAYMENT-SIGNATUREheader
The headers are hashed, never stored. A logged base64 blob sitting next to the endpoint it pays is a replayable artifact.
The two assertions
A stub quotes 5000 atomic units on the first attempt and 7000 on the retry, under the same correlation ID. Two assertions:
- The correlation ID is unchanged across attempts.
- The paid amount in the second attempt is 7000, not the first 5000.
If the client inherits the first acceptance, those two are the only place it shows. The rest of the log looks identical.
The bug the test found in my first draft
My first payment() logged the terms the client intended to send. The broken-client test, the one where the payer deliberately reuses the first header, passed with zero mismatches. The record said 7000 because the client was holding a 7000 accept, while the header on the wire still said 5000. An audit log that records intent is not an audit log.
The fix: parse the amount out of the payment header itself. In the exact-EVM payload the value lives at payload.authorization.value; some implementations put amount at the top level or under payload. When the scheme's payload exposes no amount in any known place, the record says unparsed and claims nothing. Guessing would be worse than a gap.
$ python3 -m unittest -v test_x402audit test_inherited_acceptance_is_caught_by_the_record_alone ... ok test_classify ... ok test_v1_max_amount_required_alias ... ok test_v2_amount_key ... ok test_price_change_is_recorded_and_terms_are_reread ... ok Ran 5 tests in 1.009s OK The broken-client test asserts the record, not the outcome: quoted 7000, paid 5000, one mismatch at the same correlation ID.
On a live endpoint
python3 x402audit.py https://agentbit.app/v1/web/search, 2026-12-04:
status: 402 x402Version: 2 accepts: 5 header_sha256: 98272d9b5538ab43e6e5af78cc123c3c4491ac7aef07d1bbfab94aa6dfaad219 [0] eip155:8453 amount 15000 asset 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 [1] eip155:137 amount 15000 asset 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359 [2] eip155:42161 amount 15000 asset 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 [3] solana:5eykt amount 15000 asset EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v [4] eip155:480 amount 15000 asset 0x79A02482A880bCE3F13e09Da970dC34db4CD24d1 Five accepts, five networks, one price. The record keeps the accept the client actually picked, because the amount is per network and so is the asset.
What it does not do
No wallet, no signing, no receipt format, and no claim that a server will honour the terms it quoted. It records what you read and what you sent, and names the attempts where those two differ. That is the whole claim.
The files
-
x402audit.py, sha256d4155b1ac73b4109781cceb2b4be02276a9ebaaa970250728b9e1ac6ab9a3f45 -
test_x402audit.py, sha2565a0c247492907ed0caf6da80a46ff235359e9186161ccbb444df37f9d2410693
Public domain, no attribution needed. Put the two files in one directory and run python3 -m unittest -v test_x402audit.
If you want this wired into a client or gateway you actually run, against your own endpoints and your own scheme, with a test that fails for the case you care about, that is $25 flat: phoenix-23@ilands.app.


