Skip to main content

Signing contract

ElementRequirement
Signature schemeEIP-712 typed-data signing
Signing domainDomain includes chain_id and verifying_contract
Signer identityRecovered signer must match trader identity
Replay boundaryReplay-window timing checks and duplicate-nonce detection are enforced; lower nonces can still be admitted when they are fresh and non-duplicate
Replay-window pairingclient_timestamp_ms and recv_window_ms must be supplied as one complete pair; zero/default or partial population is rejected by the live gateway
Failure on mismatchSignatureRecoveryMismatch safety failure

Request families

ClientRequestApiSchema currently includes these request variants in the checked source:
VariantNote
OrderAlways present in the checked schema surface
ModifyOrderAlways present in the checked schema surface
CancelOrderAlways present in the checked schema surface
CancelAllAlways present in the checked schema surface
WithdrawAlways present in the checked schema surface
WithdrawDDXAlways present in the checked schema surface
InsuranceFundWithdrawPresent only when the insurance_fund_client_req feature is enabled
ProfileUpdateAlways present in the checked schema surface

Required signing inputs

InputRole
trader identityDetermines recovered signer match
strategy identifierBinds request to the correct strategy where applicable
request payloadExact action details that are hashed and signed
nonceDuplicate detection key within replay-window policy and retained-idempotency behavior
chain_idEIP-712 domain separator input
verifying_contractEIP-712 domain separator input
session_key_signatureOptional delegated session payload bytes when session keys are used

Replay-window field states

Field stateSerialized shapePublic gateway behavior
Missingclient_timestamp_ms = 0 and recv_window_ms = 0Rejected as 400 InvalidRequestPayload with missing replay-window detail
Incompleteone replay-window field set while the other remains zeroRejected as 400 InvalidRequestPayload with malformed replay-window detail
Completeboth replay-window fields populatedContinues to replay-window freshness and duplicate-state validation

Replay-window nuance

DerivaDEX live sequencing is not modeled as one globally increasing nonce stream for every request family.
RuleNotes
Freshness gateLive signed requests must present a complete replay-window pair and then satisfy timestamp and recvWindow validation
Duplicate handlingRetained duplicates can return stored outcomes; pending duplicates can be rejected
Lower-nonce edge caseRegression tests explicitly cover fresh lower-nonce CancelOrder and CancelAll requests remaining admissible when they are non-duplicate and still inside the replay window
Client guidanceGenerate unique increasing nonces anyway because they simplify reconciliation, logging, and cross-family replay avoidance

Failure classes tied to signing and replay

Error reasonStatusMeaning
InvalidRequestPayload400Request body is malformed, including missing or partially populated replay-window fields
SignerNotFound401Recovered signer does not exist in verified state
SessionUnauthorized401Delegated session proof failed policy checks
IllegalNonce412Nonce conflicts with replay/duplicate-state policy for the request family
ExpiredTimestamp412Request timestamp is too old
FutureTimestamp412Request timestamp is too far in the future
SignatureRecoveryMismatch422Signature and trader identity do not match

Validation coupling

Signing is validated alongside pre-trade checks such as market support, tick-size, minimum-order-size, notional cap, collateral sufficiency, and margin constraints.
Last modified on April 13, 2026