LightAccount
LightAccount¶
LightAccount smart contract wallet operations.
Initialize LightAccount (internal use - use from_api() instead).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
AuthContext
|
Authentication context for signing operations |
required |
config
|
EnvConfig
|
Environment configuration |
required |
public_api
|
PublicAPI
|
Public API interface |
required |
private_api
|
PrivateAPI
|
Private API interface for authenticated requests |
required |
_state
|
PrivateGetAccountResultSchema | None
|
Initial state (internal use only) |
None
|
Attributes¶
Functions¶
build_register_session_key_tx
¶
build_register_session_key_tx(
*,
expiry_sec: int,
public_session_key: str,
gas: Optional[int] = None,
nonce: Optional[int] = None
) -> PublicBuildRegisterSessionKeyTxResultSchema
NOT SUPPORTED PROGRAMMATICALLY: registering a session key (paymaster flow) cannot be executed from this client.
Options: - Use the Derive frontend (recommended) so the paymaster pays gas. - To register programmatically, use an owner-signed, EOA-paid flow: client.owner.build_register_session_key_tx(...)
create_subaccount
¶
create_subaccount(
*,
amount: Decimal = Decimal("0"),
asset_name: str = "USDC",
margin_type: MarginType = SM,
nonce: Optional[int] = None,
signature_expiry_sec: Optional[int] = None,
currency: Optional[str] = None
) -> PrivateCreateSubaccountResultSchema
Create subaccount.
deregister_session_key
¶
deregister_session_key(
*, public_session_key: str, signed_raw_tx: str
) -> PublicDeregisterSessionKeyResultSchema
NOT SUPPORTED PROGRAMMATICALLY: deregistering a session key (paymaster flow) cannot be executed from this client.
Options: - Use the Derive frontend to deregister so paymaster handles flow. - To deregister programmatically, use an owner-signed, EOA-paid flow: client.owner.deregister_session_key_via_eoa(...)
edit_session_key
¶
edit_session_key(
*,
public_session_key: str,
disable: bool = False,
ip_whitelist: Optional[list[str]] = None,
label: Optional[str] = None
) -> PrivateEditSessionKeyResultSchema
Edits session key parameters such as label and IP whitelist.
from_api
classmethod
¶
from_api(
*,
auth: AuthContext,
config: EnvConfig,
logger: LoggerType,
public_api: PublicAPI,
private_api: PrivateAPI
) -> LightAccount
Validate LightAccount by fetching its state from the API.
This performs a network call to verify the wallet exists and that the provided session key is registered and valid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
AuthContext
|
Authentication context for signing operations |
required |
config
|
EnvConfig
|
Environment configuration |
required |
public_api
|
PublicAPI
|
Public API interface |
required |
private_api
|
PrivateAPI
|
Private API interface for authenticated requests |
required |
Returns:
| Type | Description |
|---|---|
LightAccount
|
Initialized LightAccount instance |
Raises:
| Type | Description |
|---|---|
APIError
|
If wallet does not exist |
get_all_portfolios
¶
get_all_portfolios() -> (
list[PrivateGetSubaccountResultSchema]
)
Get all subaccount portfolios of a wallet
get_subaccounts
¶
get_subaccounts() -> PrivateGetSubaccountsResultSchema
Get all subaccount IDs of an account / wallet
register_scoped_session_key
¶
register_scoped_session_key(
*,
expiry_sec: int,
public_session_key: str,
ip_whitelist: Optional[list[str]] = None,
label: Optional[str] = None,
scope: Scope = read_only,
signed_raw_tx: Optional[str] = None
) -> PrivateRegisterScopedSessionKeyResultSchema
register_session_key
¶
register_session_key(
*,
expiry_sec: int,
label: str,
public_session_key: str,
signed_raw_tx: str
) -> PublicRegisterSessionKeyResultSchema
NOT SUPPORTED PROGRAMMATICALLY: registering a session key (paymaster flow) cannot be executed from this client.
Options: - Use the Derive frontend (recommended) so the paymaster pays gas. - To register programmatically, use an owner-signed, EOA-paid flow: client.owner.register_session_key_via_eoa(...)
session_keys
¶
session_keys() -> PrivateSessionKeysResultSchema
Registered session keys, including details (expiry, scope, IP whitelist)
A session key is simply an Ethereum wallet. Account owners can give other Ethereum wallets temporary access to their accounts via session keys.
set_cancel_on_disconnect
¶
set_cancel_on_disconnect(enabled: bool = True) -> Result
Enables cancel on disconnect for the account.