Every POST /exchange request includes a nonce — an integer that the server uses to prevent replay attacks. Because the nonce is embedded in the signed message, an attacker who intercepts a valid signed request cannot resubmit it: the server recognises and rejects any nonce it has already seen from that signer.
What Is the Nonce?
The nonce is an int64 (64-bit signed integer) included at the top level of every POST /exchange envelope alongside action and signature. It is part of the signed message, so any tampering with the nonce value will invalidate the signature.
Recommended Value
Use the current Unix timestamp in milliseconds. This is a natural choice because it is:
- Monotonically increasing — subsequent requests naturally have higher nonces.
- Unique — millisecond resolution makes accidental collisions unlikely in normal usage.
- Self-documenting — you can decode the approximate time of any request from its nonce.
Millisecond timestamps are sufficient for most use cases. If you need to fire more than one request per millisecond, increment the nonce by 1 for each additional request within the same millisecond.
Code Examples
Python
JavaScript / TypeScript
Go
Rules
Rapid Succession Requests
If you need to submit multiple requests faster than one per millisecond, read the current timestamp once and increment:
Do not reuse a nonce under any circumstances — even after a failed request. The server may have partially processed the request before returning an error, and reusing the nonce will cause the retry to be rejected.