Authentication
Authentication¶
To interact with Derive using the client, you first need to register and configure your accounts. This involves creating a LightAccount, Subaccount, and Session Key.
At the moment, registration is done via the Derive web app. Programmatic account creation is not yet supported by this client (TODO).
What You Need¶
- Session Key Private Key:
The EOA private key for the session key you registered (this can be the owner EOA or a secondary signer). - LightAccount Address:
The smart contract wallet that holds your funds on Derive. - Subaccount ID:
The trading account within your LightAccount. - Currently optional in the client: if omitted, the first subaccount will be used.
- Best practice: always provide explicitly to avoid ambiguity.
Step 1. Generate a Private Key¶
You can generate a private key using the helper script:
python ./scripts/create-private-key.py
Or use an existing key
Step 2: Create Your LightAccount¶
- Visit derive.xyz
- Connect your wallet and create an account
- This creates your LightAccount (funding wallet)
- Copy the LightAccount address from the Developer section
Step 3: Create a Subaccount¶
- Go to the Developers section
- Click Create Subaccount
- Select your margin type: Standard or Portfolio
- Name the subaccount
- Click Create Subaccount
Step 4: Register a Session Key¶
- In the Developers section
- Click Register Session Key
- Provide the EOA you want to use as a session key (can be the owner or a secondary signer)
- Select permissions (Admin / Account / Read-only) and expiry
- Navigate to Subaccounts
- Note your Subaccount ID
⚠️ Important:
- Even the owner EOA must be registered as a session key in order to trade on Derive.
- This client currently only supports bridging when using the owner EOA. This is a deliberate precaution to prevent confusion and mistakes. See Bridging & Funding for details.
Step 5: Store Your Credentials¶
You will need the following information to use the client:
export DERIVE_SESSION_KEY=0x742d... # Required: EOA private key registered as a session key
export DERIVE_WALLET=0x8f5B... # Required: LightAccount (smart contract wallet) address
export DERIVE_SUBACCOUNT_ID=123456 # Required: Subaccount ID
Next: Bridging & Funding - How to fund your accounts and get ready to trade.