Signature Format
Most/exchange actions use a top-level nonce plus a top-level raw ECDSA signature:
reportDepositis unsigned. -acceptTermsuses a top-level hex signature string and does not use a nonce. -approveAgent, trading actions, referral actions such asgetReferralCodeandcreateReferralCode, and TWAP actions use the{(r, s, v)}+noncewrapper shown above. - Withdrawals also use the{(r, s, v)}+noncewrapper, but the signed payload is the withdrawal action fields. - Withdrawals must be signed by the user account, not by an approved agent wallet.
Nonce
Thenonce is an integer used to prevent replay attacks. In practice clients typically use a millisecond timestamp:
Signature Components
The signature consists of three components (standard ECDSA):r- First 32 bytes of signature (hex string)s- Second 32 bytes of signature (hex string)v- Recovery ID. Most trading actions accept0-255; withdrawals require27or28.
Creating Signatures
Trading Actions
Orders, cancels, modifies, and leverage updates are verified from the raw action payload plusnonce. Use the Notional SDK or the exact client implementation for canonical action normalization and signing.
Use the Notional SDK for exact typed-data definitions and action normalization.
Terms Acceptance
acceptTerms is the exception to the nonce-based pattern. It sends the typed-data signature as a top-level hex string:
Withdrawals
Withdrawals still use the outernonce + { r, s, v } wrapper, but the signed fields live inside action:
signatureChainId selects the EIP-712 domain for signature recovery. The signed withdrawal payload is:
notionalChaindestinationtokenamountsourcetime
Agent Approval
Instead of signing each request with your main wallet, you can authorize an API wallet (agent) to sign on your behalf.Benefits
- Security: Keep your main wallet offline
- Convenience: No manual signature approval for each trade
- Automation: Enable trading bots and automated strategies
Approving an Agent
Send anapproveAgent action signed by your main wallet:
Using an Approved Agent
Once approved, the agent can sign trading requests on behalf of the user:- Agent creates the action payload
- Agent signs the action with its own private key
- Backend validates:
- Signature is valid for agent address
- Agent is approved for the user
- Action is authorized
userAddress is recovered from the approval record, not the signature.
Agent wallets can place and manage trades, but they cannot initiate withdrawals.
Validation Process
When a nonce-based signed request arrives, the backend:- Validates signature structure - Checks r, s, v format
- Recovers signer address - Uses ECDSA recovery
- Checks authorization:
- If signer = user → Direct mode (approved)
- If signer = agent → Agent mode (checks approval table)
- Verifies nonce - Ensures uniqueness
- Validates action - Checks order parameters, margin, etc.
Error Responses
Invalid Signature
Agent Not Approved
Duplicate Nonce
Security Best Practices
- Never share your private key - Use hardware wallets for main account - Limit agent permissions - Only approve agents you trust - Monitor agent activity - Review orders placed by agents - Rotate agents - Revoke and re-approve agents periodically - Use unique nonces
- Ensure timestamp-based nonces are unique
