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
Derive the subaccount key from a signature by the main wallet (recommended), so the key can always be recovered from the wallet.
Sign
CreateSubaccountwith the main wallet or one of the main account's signing keys.Sign
LinkSubaccountwith the subaccount key.Send both signatures to
POST /subaccountswith 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.
The main wallet signs the EIP-712 message
SubaccountSeed:SubaccountSeed(address account,uint256 version)with
account= the main account address andversion=1.seed = keccak256(signature[0:64]). Use the first 64 bytes of the 65-byte signature (rands); leave outv.For subaccount number
i(starting at1):subaccount_private_key = keccak256(seed ‖ uint32_big_endian(i))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:
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
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?

