Documentation Index
Fetch the complete documentation index at: https://docs.prudra.dev/llms.txt
Use this file to discover all available pages before exploring further.
Replay attack protection
A replay attack on a payment system occurs when a valid payment credential (transaction hash or signed authorization) is submitted more than once to get double the service. Prudra prevents this with a UNIQUE constraint at the database level — not at the application level.Why database-level, not application-level
Application-level uniqueness checks have a race condition window. Two concurrent requests carrying the sametxHash can both pass the application-level check before either write commits to the database:
txHash succeeds, even under concurrent load:
The 409 response
When a duplicate payment is detected:What gets a UNIQUE constraint
| Protocol | Unique field | Scope |
|---|---|---|
| x402 | ERC-3009 nonce | Per USDC contract |
| MPP | Transaction hash | Globally |
txHash of the Tempo transaction is globally unique by design — no two transactions can have the same hash.
Testing replay protection
In stub mode, Prudra uses the stub credential value itself as the txHash for uniqueness checking. This lets you test replay protection without real transactions.
No action required
Replay protection is handled automatically by Prudra middleware. You don’t need to implement any uniqueness checking in your handler code. If a 409 is returned to your handler (which shouldn’t happen — the middleware catches it before your handler runs), it means a concurrent request with the same credential slipped through, which is not possible with the UNIQUE constraint in place.Related
- Prevent challenge harvesting — rate limiting and no-challenge-on-error
- Payment audit logs — how payments are logged for audit
- How x402 works — the nonce in ERC-3009 signing
- How MPP works — txHash verification on Tempo

