Sign DerivaDEX requests with EIP-712
Use this when you need a clear implementation of the signing flow DerivaDEX expects. The examples use Python because the procedure is easiest to read there, but the same steps apply in any language that can build the same bytes and hashes. You need thechainId, the DerivaDEX verifying smart contract address, the exact request you plan to send, and the wallet key that controls the trader account.
Use the network values you are signing for:
After the signature is correct, move to How to Encrypt Requests for the Operator.
Follow the signing procedure
- Define the EIP-191 prefix.
-
Build the EIP-712 domain separator from the
chainIdand the DerivaDEX verifying smart contract address. Use the same domain values for every request: -
Choose the request type you are signing, then build its message hash with the exact field order DerivaDEX expects.
-
Compute the final digest as
keccak256(EIP191_HEADER + domain_separator + message_struct_hash). - Sign that digest with the trader wallet.
- Recover the signer locally before submission and confirm that it matches the trader wallet you expect.
Worked examples
Start with the helper functions that stay the same across request types. Each request type can be implemented in two ways here:Direct implementationshows the hashing steps directly.DDX client libraryshows the shortest path if you already use the library.
Example: sign an order request
This example follows the steps above forOrderParams.
Direct implementation
DDX client library
If you already useddx-python, this is the shortest path through the same procedure:
Sign the hash and recover the signer
Once the EIP-712 hash is correct, signing it is the short final step. This example uses a generated wallet only to show the mechanics:Check your result before you submit
- Recover the signing address from the signature and digest.
- Confirm that it matches the trader wallet you expect to authorize the request.
SignedRequestAuthenticationFailed.
Appendix
Use this section when you need the exact field rules behind the steps and examples.
Profile updates need three extra rules:
Continue with submission
After the signature is correct, fetch the operator key, encrypt the signed JSON, and submit the bytes toPOST /v2/request. Use How to Encrypt Requests for the Operator for that step.
If the request still fails after local recovery matches the trader wallet, use Error Reference for the exact rejection path.