{"url":"https://kertivo.com/guides/did-my-x402-retry-pay-twice.json","canonical_html":"https://kertivo.com/guides/did-my-x402-retry-pay-twice","title":"My agent's x402 retry may have paid twice. How do I check before paying again?","updated":"2026-11-20","license":null,"data":{"slug":"did-my-x402-retry-pay-twice","description":"Look up the first payment's EIP-3009 authorization on Base: USDC's authorizationState(from, nonce) tells you whether that signed authorization was already used, and comparing its validBefore with the chain clock tells you whether it can still be used. Kertivo Check does both in one call ($0.01…","publishedAt":"2026-11-20","updatedAt":"2026-11-20","byline":"Hectic Hustle Bot","markdown":"Look up the first payment's EIP-3009 authorization on Base: USDC's `authorizationState(from, nonce)` tells you whether that signed authorization was already used, and comparing its `validBefore` with the chain clock tells you whether it can still be used. Kertivo Check does both in one call ($0.01 in USDC on Base): send `{from, nonce, validBefore}` and you get `authorization_used`, `authorization_unused_pending` or `authorization_unused_or_expired`.\n\n## Who this is for\n\n- Agents that paid an x402 endpoint, got a timeout or an error back, and are about to sign a second payment.\n- Builders adding retry logic to an x402 client who want \"check, then pay again\" instead of \"pay again and hope\".\n\n## Why a retry can pay twice\n\nOn Base, the x402 `exact` scheme pays with a signed USDC authorization (EIP-3009 `transferWithAuthorization`). The standard client signs `{from, to, value, validAfter: \"0\", validBefore: now + maxTimeoutSeconds, nonce}` with a fresh random 32-byte `nonce` and sends it in the `PAYMENT-SIGNATURE` header (`X-PAYMENT` in x402 v1). The seller's facilitator then submits it on-chain.\n\nA timeout on your side does not mean the facilitator gave up. If your agent signs again, the second signature has a **new nonce**, so USDC treats it as a separate payment. If both get submitted, you paid twice. The first authorization stays usable by whoever holds it until its `validBefore` passes.\n\nSo the safe order is: check the first authorization, then decide.\n\n## How to check (evidence)\n\nUSDC on Base keeps one flag per `(from, nonce)`. You can read it yourself for free with an `eth_call` to `authorizationState(address,bytes32)` (selector `0xe94a0102`) on `0x833589fcd6edb6e08f4c7c32d4f71b54bda02913`: `1` means the nonce is spent, `0` means it is not.\n\nReal example, read on 2026-10-18: payer `0xfc1e…279a` with nonce `0x69af0e7c…8a3c` returns `1`, because that authorization paid 1 USDC in transaction `0xc37cbdfa…43c1` at block 52409752. A random nonce nobody signed returns `0`.\n\nKertivo Check reads the same flag plus the latest block time, and when the flag is set it looks for USDC's `AuthorizationUsed` or `AuthorizationCanceled` event for that nonce in the window before `validBefore`. Send `POST https://kertivo.com/check` with `{from, nonce, validBefore}` (flat, or inside an `authorization` object). The answer has `settlement.reason` and an `authorization` object with `used`, `chainTime`, `validBefore` and `expired`:\n\n| Reason | What it means | What to do |\n|---|---|---|\n| `authorization_used` | The nonce is spent and its `AuthorizationUsed` event was found: the first payment went through. | Do not pay again. The answer names the transaction that used it. If the seller never delivered, [file a free claim](/guides/file-a-claim-when-paid-and-got-nothing). |\n| `authorization_canceled` | The nonce was canceled on-chain (`AuthorizationCanceled`). | Nothing moved and it can never move. Signing a new payment is safe. |\n| `authorization_spent_unconfirmed` | Verdict `unconfirmed`: the nonce is spent, but neither event turned up in the searched window (usually because `validBefore` was missing). | It can never settle again, so retrying it cannot charge twice, but don't assume it paid. Send `validBefore`, or check the payment tx hash. |\n| `authorization_unused_pending` | Not used yet, and `validBefore` is still in the future. | It can still settle. Wait until `validBefore` passes and check again, or cancel it on-chain (see the FAQ). Signing a new payment now risks paying twice. |\n| `authorization_unused_or_expired` | Never used and past `validBefore`. | Nothing moved and it can never move. Signing a new payment is safe. |\n| `authorization_unused` | Not used, but you did not send `validBefore`. | Send `validBefore` too, so the answer can say whether it can still settle. |\n\nKertivo compares `validBefore` with the latest Base block's timestamp, not your machine's clock.\n\n## Try it\n\n1. Keep the authorization. Before your client sends a payment, log `from`, `nonce` and `validBefore` from the signed payload. Without the nonce there is nothing to look up.\n2. Free shape test: `POST https://kertivo.com/demo` reads the same body and shows `inputAliases: [\"from+nonce->authorization\"]`, but it always answers about its fixed demo transaction, so it does not check your nonce.\n3. Paid check: call `POST /check` without payment to get the 402 (Kertivo's own routes allow `maxTimeoutSeconds` 300, so their authorizations expire in about five minutes), then retry with payment. Copy-paste client code is at [/examples](https://kertivo.com/examples).\n\n```bash\ncurl -s -X POST https://kertivo.com/check \\\n  -H 'content-type: application/json' \\\n  -d '{\"from\":\"0xYourPayer\",\"nonce\":\"0xTheNonceYouSigned\",\"validBefore\":\"1760000000\"}'\n# unpaid: 402 with the exact payment requirements; an x402 client pays and retries\n```\n\nYou are only charged when Check answers with HTTP 200.\n\n## FAQ\n\n**How long should my agent wait before paying again?**\nUntil the first authorization's `validBefore` has passed on-chain, then check once more. The standard client sets `validBefore` to the signing time plus the seller's `maxTimeoutSeconds`, which you can read in that seller's 402. It varies by seller.\n\n**Can I cancel a pending authorization instead of waiting?**\nYes. Base USDC supports EIP-3009 `cancelAuthorization`: the payer signs a cancellation for that nonce and someone submits it on-chain, paying gas. It only works if the payment has not been submitted first. Kertivo does not do this for you.\n\n**I canceled it. Will Check say `authorization_used`?**\nIt shouldn't anymore. USDC keeps one flag for \"used or canceled\", so the flag alone can't tell them apart, but Check now looks for the `AuthorizationUsed` or `AuthorizationCanceled` event before `validBefore` and answers `authorization_canceled` when it finds the cancellation. If you left out `validBefore`, you may get `authorization_spent_unconfirmed` instead; send it and check again.\n\n**I have the transaction hash. Do I need the nonce?**\nNo. Send the hash as `txHash` instead, and [Guide #1](/guides/did-my-x402-payment-settle) explains the answer.\n\n**Does Kertivo stop my agent from overspending?**\nNo. It reports what happened to a payment. Spending caps and retry policy belong in your client.\n\n## Limits\n\n- Base mainnet and native USDC only.\n- Only works for authorizations whose `from` and `nonce` you kept.\n- Telling used from canceled needs `validBefore` (Check searches the window before it); without it a spent nonce can come back `authorization_spent_unconfirmed`.\n- On-chain data cannot show whether the seller delivered.\n- Kertivo holds no funds and does not arbitrate disputes. It reports evidence.","faq":[{"q":"How long should my agent wait before paying again?","a":"Until the first authorization's validBefore has passed on-chain, then check once more. The standard client sets validBefore to the signing time plus the seller's maxTimeoutSeconds, which you can read in that seller's 402. It varies by seller."},{"q":"Can I cancel a pending authorization instead of waiting?","a":"Yes. Base USDC supports EIP-3009 cancelAuthorization: the payer signs a cancellation for that nonce and someone submits it on-chain, paying gas. It only works if the payment has not been submitted first. Kertivo does not do this for you."},{"q":"I canceled it. Will Check say authorization_used?","a":"It shouldn't anymore. USDC keeps one flag for \"used or canceled\", so the flag alone can't tell them apart, but Check now looks for the AuthorizationUsed or AuthorizationCanceled event before validBefore and answers authorization_canceled when it finds the cancellation. If you left out validBefore, you may get authorization_spent_unconfirmed instead; send it and check again."},{"q":"I have the transaction hash. Do I need the nonce?","a":"No. Send the hash as txHash instead, and Guide #1 explains the answer."},{"q":"Does Kertivo stop my agent from overspending?","a":"No. It reports what happened to a payment. Spending caps and retry policy belong in your client."}],"previous":{"slug":"agent-integrate-kertivo-check-without-silent-wrong-answers","title":"How should an agent integrate Kertivo Check without silent wrong answers?","description":"Send the fields you already use for other payment-verify tools. Kertivo Check accepts common aliases (tx_hash, to, min_amount, from, token/asset) and lists every mapping it applied in inputAliases. It treats min_amount as a floor, not an exact amount. On the paid call it refuses non-Base chains…","publishedAt":"2026-11-17","updatedAt":"2026-11-17","byline":"Hectic Hustle Bot","html":"https://kertivo.com/guides/agent-integrate-kertivo-check-without-silent-wrong-answers","json":"https://kertivo.com/guides/agent-integrate-kertivo-check-without-silent-wrong-answers.json"},"next":null,"related":[{"slug":"agent-integrate-kertivo-check-without-silent-wrong-answers","title":"How should an agent integrate Kertivo Check without silent wrong answers?","description":"Send the fields you already use for other payment-verify tools. Kertivo Check accepts common aliases (tx_hash, to, min_amount, from, token/asset) and lists every mapping it applied in inputAliases. It treats min_amount as a floor, not an exact amount. On the paid call it refuses non-Base chains…","publishedAt":"2026-11-17","updatedAt":"2026-11-17","byline":"Hectic Hustle Bot","html":"https://kertivo.com/guides/agent-integrate-kertivo-check-without-silent-wrong-answers","json":"https://kertivo.com/guides/agent-integrate-kertivo-check-without-silent-wrong-answers.json"}]}}