DeriveApiClient
Documentation for eth_defi.derive.authentication.DeriveApiClient Python class.
- class DeriveApiClient
Bases:
objectDerive API client with session key authentication.
This client handles:
Authenticated JSON-RPC 2.0 requests via HTTP
Signing requests with EIP-191 personal-sign (encode_defunct)
Authentication headers follow the Derive convention:
X-LYRAWALLET: <smart contract wallet address> X-LYRATIMESTAMP: <UTC timestamp in milliseconds> X-LYRASIGNATURE: <EIP-191 signature of the timestamp string>
Example:
from eth_account import Account from eth_defi.derive.authentication import DeriveApiClient # Initialise with owner account owner = Account.from_key("0x...") client = DeriveApiClient( owner_account=owner, derive_wallet_address="0x...", is_testnet=True, ) # Make authenticated request using owner key directly result = client._make_jsonrpc_request( method="private/get_subaccounts", params={"wallet": client.derive_wallet_address}, authenticated=True, )Initialise Derive API client.
- Parameters
owner_account – Owner wallet (EOA) for signing session key registrations.
derive_wallet_address – Derive wallet address (LightAccount smart contract wallet on Derive Chain). For manual onboarding this equals the counterfactual LightAccount address derived from the owner EOA.
subaccount_id – Subaccount ID to use for requests (defaults to 1).
is_testnet – Whether to use testnet API endpoint.
session_key_private – Private key of registered session key (hex string starting with 0x).
Methods summary
__init__([owner_account, ...])Initialise Derive API client.
- __init__(owner_account=None, derive_wallet_address=None, subaccount_id=1, is_testnet=False, session_key_private='')
Initialise Derive API client.
- Parameters
owner_account (eth_account.signers.local.LocalAccount | None) – Owner wallet (EOA) for signing session key registrations.
derive_wallet_address (Optional[eth_typing.evm.HexAddress]) – Derive wallet address (LightAccount smart contract wallet on Derive Chain). For manual onboarding this equals the counterfactual LightAccount address derived from the owner EOA.
subaccount_id (int) – Subaccount ID to use for requests (defaults to 1).
is_testnet (bool) – Whether to use testnet API endpoint.
session_key_private (str) – Private key of registered session key (hex string starting with 0x).