WalletManager
The WalletManager class is the core of use-wallet, responsible for managing wallet connections, network configurations, and state persistence. It provides a framework-agnostic API that serves as the foundation for the React, Vue, SolidJS, and Svelte adapters.
Constructor
constructor(config?: WalletManagerConfig)Creates a new WalletManager instance with optional configuration.
Parameters
interface WalletManagerConfig {
wallets?: SupportedWallet[]
networks?: Record<string, NetworkConfig>
defaultNetwork?: string
options?: WalletManagerOptions
}wallets- Array of wallet providers to enable (see Configuration for details)networks- Custom network configurations (optional, defaults provided)defaultNetwork- Network to use on first load (optional, defaults to 'testnet')options- Additional configuration options (optional)
interface WalletManagerOptions {
resetNetwork?: boolean // Reset to default network on page load
debug?: boolean // Enable debug logging
logLevel?: LogLevel // Set specific log level
}Example
Properties
algodClient
Algod client instance for the active network. Updates automatically when switching networks.
activeNetwork
Currently active network identifier (e.g., 'mainnet', 'testnet').
networkConfig
Complete network configuration object containing settings for all networks.
activeNetworkConfig
Configuration object for the currently active network.
wallets
Array of initialized wallet provider instances.
activeWallet
Currently active wallet provider instance, if any.
activeWalletAccounts
Array of accounts available in the active wallet.
activeWalletAddresses
Array of addresses available in the active wallet.
activeAccount
Currently active account in the active wallet.
activeAddress
Address of the currently active account.
store
TanStack Store instance containing wallet state. Used internally by framework adapters.
isReady
Whether all wallet providers have completed initialization.
Methods
getWallet
Get a specific wallet provider instance by ID.
resumeSessions
Resume previously connected wallet sessions. Called automatically by framework adapters.
disconnect
Disconnect all connected wallets.
setActiveNetwork
Switch to a different network.
updateAlgodConfig
Update Algod client configuration for a specific network.
resetNetworkConfig
Reset network configuration to default values.
signTransactions
Sign transactions using the active wallet. Delegates to the active wallet's signTransactions method.
transactionSigner
Typed transaction signer for use with AtomicTransactionComposer. Delegates to the active wallet's transactionSigner method.
Events
The WalletManager includes several event handlers that can be used to track state changes:
subscribe
Subscribe to state changes. Returns an unsubscribe function.
Example
Framework Integration
The WalletManager can be used directly with the subscribe method to implement custom reactivity, or through one of the official framework adapters that provide hooks/composables for common frameworks:
See these guides for more information:
The WalletManager's framework-agnostic design makes it possible to create adapters for other frameworks. Community contributions for additional framework adapters (e.g., Svelte, Angular) are welcome!
Last updated