Overview
TheWalletManager class is the central orchestrator of use-wallet. It manages wallet initialization, network configuration, state persistence, and provides access to wallet functionality through a reactive store.
Initialization
Configuration
WalletManagerConfig
TheWalletManager constructor accepts a configuration object:
Array of wallet IDs or wallet configuration objects. See Supported wallets for details.
Network configurations for different Algorand networks. See Network configuration for details.Defaults to mainnet, testnet, betanet, fnet, and localnet configurations using Nodely API endpoints.
The network to use by default. Must match a key in the
networks configuration.Optional manager configuration:
If
true, ignores the persisted active network and uses defaultNetwork on initialization.Shortcut to set log level to DEBUG. Overridden by
logLevel if both are provided.Explicit log level:
LogLevel.DEBUG, LogLevel.INFO, LogLevel.WARN, LogLevel.ERROR, or LogLevel.NONE.Type definitions
WalletManagerConfig
SupportedWallet
Core properties
Store and subscriptions
The TanStack Store instance managing reactive state. See State management for details.
Subscribe to state changes. Returns an unsubscribe function.
Manager status
Current manager status. Use
isReady for a boolean check.Returns
true when the manager has completed initialization and session resumption.Wallet access
Array of all initialized wallet instances.
The currently active wallet instance, or
null if no wallet is active.All accounts from the active wallet.
Array of addresses from the active wallet’s accounts.
The active account within the active wallet.
The address of the active account. Commonly used for transaction building.
Network access
The ID of the currently active network (e.g.,
'testnet').Configuration for the active network.
All configured networks.
The algod client for the active network. Automatically updated when switching networks.
Methods
Wallet management
Get a wallet instance by its wallet key.
Resume all previously active wallet sessions. Call this after initialization.
Disconnect all connected wallets.
Network management
Switch to a different network. Updates
algodClient and persists the change.Update the algod configuration for a specific network. If the network is active, the
algodClient is updated immediately.Reset a network’s configuration to its original default. Removes any customizations from persisted state.
Transaction signing
signTransactions
(txnGroup: Transaction[] | Uint8Array[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>
Sign transactions using the active wallet. Returns an array where signed transactions are
Uint8Array and unsigned transactions (skipped by indexesToSign) are null.Throws an error if no wallet is active.
An
algosdk.TransactionSigner compatible function for use with AtomicTransactionComposer.State persistence
TheWalletManager automatically persists state to localStorage under the key @txnlab/use-wallet:v4. The following data is persisted:
- Connected wallets and their accounts
- Active wallet and active account
- Active network
- Custom network configuration overrides
The manager automatically saves state changes and loads persisted state on initialization. No manual intervention is required.
Example usage
Related
Supported wallets
View all supported wallets and their configuration options
Network configuration
Learn about network configuration and customization
State management
Understand the reactive state system