Class WalletFactory
Implements
- WalletFactory
Index
Constructors
Methods
Constructors
constructor
Create a new WalletFactory instance
Parameters
Optionalprovider: IProviderOptional provider instance. If not provided, creates a default KleverProvider
Returns WalletFactory
Methods
createWallet
Create a wallet instance appropriate for the current environment
Detects the runtime environment and creates:
- NodeWallet in Node.js (requires privateKey)
- BrowserWallet in browsers (optional privateKey, defaults to extension mode)
- Throws error for React Native (not yet implemented)
Parameters
Optionalconfig: WalletConfigOptional wallet configuration
privateKey
Private key for wallet initialization (required for Node.js)
pemContent
PEM file content (alternative to privateKey)
pemPassword
Password for encrypted PEM files
network
Network to connect to ('mainnet', 'testnet', etc.)
provider
Override the factory's provider
Returns Promise<Wallet>
Wallet instance ready to connect
Factory for creating environment-appropriate wallet instances
WalletFactory automatically detects the runtime environment (Node.js, Browser, React Native) and creates the appropriate wallet implementation. This provides a unified API for wallet creation across different platforms.
Automatic Environment Detection:
Benefits:
Example
Example
Example