Skip to main content

EIP-712

Orderly relies on the EIP-712 standard to authenticate wallets and accounts for critical actions, such as:
  • Account creation
  • Orderly Key addition
  • Withdrawal requests
For these actions, wallet owners will need to sign specific messages from their wallet and pass the signature through the REST APIs to complete the action. The following sections describe the steps needed to complete these actions. For other actions, such as calling trading-related RESTful APIs, a successful Orderly Key generation is required in order to use it via API authentication.

Domain

Orderly utilizes the following EIP-712 domain and types for the registration, access key, withdrawal and settle PnL processes. Note that chainId will be the id of the chain connected, which must be supported by Orderly.

Off-chain Domain

The Registration and AddOrderlyKey types are entirely processed off-chain, which is why the verifyingContract is set to 0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC.

On-chain Domain

Any other type uses the on-chain domain. The address for the Ledger contract on the Orderly L2 chain can be looked up here.

Message Types

The message types are required for the EIP-712 algorithm to do a proper signing. Here is a list of all message types as JSON:

Orderly Key

Orderly uses the ed25519 elliptic curve standard for Orderly keys. Users can generate Orderly keys using any public ed25519 libraries and then be added to any account through the REST API. An Orderly Key is necessary to perform API authentication. Orderly Key scopes are independent. Granting one scope does not grant any other scope:
  • read: Accesses private account data from endpoints that require read, plus designated account and risk configuration APIs such as POST /v1/client/leverages and POST /v1/client/maintenance_config.
  • trading: Accesses order and trading operations that require the trading scope. A key with trading alone does not receive read access.
  • asset: Accesses asset operations that require the asset scope.
For a normal trading integration that also reads balances, positions, or other private account data, assign both scopes as read,trading. A key with only trading cannot call endpoints that require read. Add asset separately when the integration needs asset operations.
Orderly keys also have expirations for security reasons. The maximum allowed expiration of an Orderly Key is 365 days.
[!IMPORTANT] Prerequisites: Before binding an Orderly Key, you must first register your account. If the account does not exist on the network, key registration will fail. Refer to Accounts for registration instructions.
To add a new Orderly Key:
1

Generate an ed25519 key-pair

Any public ed25519 library can be used (such as this one).
2

Obtain signature from EIP-712

Sign a message from the wallet in the following format using the EIP-712 standard and obtain the signature
where:
3

Add Orderly Key

Send all the necessary information via Add Orderly Key API.

Full example