Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Creating subaccounts

A subaccount is an Ethereum address with its own private key. To create one, the main account proves it owns the subaccount, and the subaccount's key proves it agrees to be linked. Both signatures go into one request to POST /subaccounts.

Overview

  1. Derive the subaccount key from a signature by the main wallet (recommended), so the key can always be recovered from the wallet.

  2. Sign CreateSubaccount with the main wallet or one of the main account's signing keys.

  3. Sign LinkSubaccount with the subaccount key.

  4. Send both signatures to POST /subaccounts with the main account's API key.

Step 1. Derive the subaccount key

Aevo derives subaccount keys from the main wallet, so you never need to store them. The app uses this exact scheme. If you use it too, subaccounts you create through the API also work in the app, including transfers back to the main account.

  1. The main wallet signs the EIP-712 message SubaccountSeed:

    SubaccountSeed(address account,uint256 version)

    with account = the main account address and version = 1.

  2. seed = keccak256(signature[0:64]). Use the first 64 bytes of the 65-byte signature (r and s); leave out v.

  3. For subaccount number i (starting at 1):

    subaccount_private_key = keccak256(seed ‖ uint32_big_endian(i))
  4. The subaccount address is the address of that private key.

Use the lowest i whose address isn't already one of your subaccounts, including archived ones. GET /subaccounts lists them.

Step 2. Sign CreateSubaccount

Signed by the main wallet or one of the main account's signing keys:

  • account: the main account address.

  • subaccount: the subaccount address from step 1.

  • name: 1 to 16 characters. Letters, numbers, spaces, _ and - only, with no leading or trailing spaces. It must be unique among your active subaccounts.

Step 3. Sign LinkSubaccount

Signed by the subaccount's private key from step 1:

with the same account and subaccount values.

EIP-712 domain

All three messages use the same domain as order signing:

Mainnet
Testnet

name

Aevo Mainnet

Aevo Testnet

version

1

1

chainId

1

11155111

Step 4. Create the subaccount

The response confirms the link:

The subaccount can trade as soon as the request succeeds. Fund it with a transfer from the main account.

Errors

Error
Meaning

SUBACCOUNT_DISABLED

Subaccount creation is not enabled.

SUBACCOUNT_LIMIT_REACHED

The main account already has the maximum number of active subaccounts. Archive one, or use an existing one.

SUBACCOUNT_INVALID_NAME

The name breaks the naming rules.

SUBACCOUNT_NAME_TAKEN

Another active subaccount of this main account has the same name.

SUBACCOUNT_NOT_FRESH

The subaccount address already has an Aevo account. Use the next index.

SUBACCOUNT_NESTING

A subaccount can't own subaccounts, and an account that already owns subaccounts can't become one.

SUBACCOUNT_PARENT_INELIGIBLE

This account type can't own subaccounts.

SUBACCOUNT_INVALID_SIGNATURE

parent_signature or subaccount_signature doesn't match the request. Check the domain, the field values and which key signed each message.

Last updated

Was this helpful?