agentconnect.utils.wallet_manager module¶
Wallet persistence utilities for the AgentConnect framework.
This module provides utility functions to manage wallet data persistence for individual agents within the AgentConnect framework. It specifically facilitates the storage and retrieval of wallet state to enable consistent wallet access across agent restarts.
- set_default_data_dir(data_dir)¶
Set the default directory for wallet data storage globally.
- set_wallet_data_dir(data_dir)¶
Set a custom directory for wallet data storage.
- save_wallet_data(agent_id, wallet_data, data_dir=None)¶
Persists the exported wallet data for an agent, allowing the agent to retain access to the same wallet across restarts.
SECURITY NOTE: This default implementation stores wallet data unencrypted on disk, which is suitable for testing/demo but NOT secure for production environments holding real assets. Real-world applications should encrypt this data.
- Parameters:
agent_id (
str
) – String identifier for the agent.wallet_data (
Union
[WalletData
,str
,Dict
]) – The wallet data to save. Can be a cdp.WalletData object, a Dict representation, or a JSON string.data_dir (
Union
[str
,Path
,None
]) – Optional custom directory for wallet data storage. If None, uses the DEFAULT_DATA_DIR.
- Raises:
IOError – If the data directory can’t be created or the file can’t be written.
- Return type:
- load_wallet_data(agent_id, data_dir=None)¶
Loads previously persisted wallet data for an agent.
- Parameters:
- Return type:
- Returns:
The loaded wallet data as a JSON string if the file exists, otherwise None.
- Raises:
IOError – If the file exists but can’t be read properly.
- wallet_exists(agent_id, data_dir=None)¶
Check if wallet data exists for a specific agent.
- get_all_wallets(data_dir=None)¶
Get information about all wallet files in the specified directory.
- delete_wallet_data(agent_id, data_dir=None)¶
Delete wallet data for a specific agent.