Skip to main content

Module credential

Module credential 

Source
Expand description

Derive credential storage.

Derive identifies a trading account through a three-part tuple rather than a single API key:

  1. wallet_address: the Derive Chain smart-contract wallet (NOT the user’s EOA). This is the value placed in the X-LYRAWALLET header and the owner slot of every signed action. Visible in the Derive web app under Home -> Developers -> “Derive Wallet”.
  2. session_key: a secp256k1 private key registered to the wallet. Signs REST/WS auth headers and EIP-712 typed-data actions. May be the owner EOA’s key but is more commonly a scoped session key.
  3. subaccount_id: per-wallet integer slot that holds the positions and signs each private/order request.

§Credential resolution

Credentials are resolved in the following priority order:

  1. Explicit values from config
  2. DERIVE_WALLET_ADDRESS / DERIVE_SESSION_PRIVATE_KEY / DERIVE_SUBACCOUNT_ID env vars (or the _TESTNET_ variants when targeting testnet)

The session-key bytes are zeroized on drop.

Structs§

DeriveCredential
Derive Chain smart-contract wallet + session-key + subaccount triple.

Functions§

credential_env_vars
Returns the environment-variable triple (wallet, session_key, subaccount) for the given environment.