BaseWallet is the abstract base class that defines the common interface for all wallet providers in use-wallet. Each wallet implementation (Pera, Defly, WalletConnect, etc.) extends this class.
Properties
The wallet’s unique identifier from the WalletId enum.
walletKey
readonly walletKey : WalletKey
Unique key for this wallet instance. Used for state storage and session isolation. For most wallets this is the same as id, but for skinned WalletConnect instances it follows the pattern walletconnect:skinId.
readonly metadata : WalletMetadata
Wallet metadata including name and icon.
Display name for the wallet
Wallet icon as a data URI or URL
name
Returns the uppercase wallet ID.
accounts
get accounts (): WalletAccount []
Returns the connected accounts for this wallet.
addresses
get addresses (): string []
Returns the addresses of connected accounts.
activeAccount
get activeAccount (): WalletAccount | null
Returns the currently active account for this wallet, or null if no account is active.
activeAddress
get activeAddress (): string | null
Returns the address of the active account, or null if no account is active.
activeNetwork
get activeNetwork (): string
Returns the ID of the currently active network.
activeNetworkConfig
get activeNetworkConfig (): NetworkConfig
Returns the configuration for the currently active network.
isConnected
get isConnected (): boolean
Returns true if this wallet has connected accounts.
isActive
Returns true if this is the currently active wallet.
canSignData
Indicates whether the wallet supports arbitrary data signing. Default is false.
canUsePrivateKey
canUsePrivateKey : boolean
Indicates whether the wallet can provide access to private keys. Default is false. Only applicable to wallets like Mnemonic and Web3Auth.
Methods
connect
abstract connect ( args ?: Record < string , any > ): Promise < WalletAccount [] >
Optional wallet-specific connection arguments
Initiates the wallet connection flow. Returns a promise that resolves with the connected accounts.
const accounts = await wallet . connect ()
console . log ( 'Connected accounts:' , accounts )
disconnect
abstract disconnect (): Promise < void >
Disconnects the wallet and clears its session.
await wallet . disconnect ()
resumeSession
abstract resumeSession (): Promise < void >
Attempts to restore a previous wallet session. Called automatically by WalletManager.resumeSessions().
setActive
Sets this wallet as the active wallet in the WalletManager.
setActiveAccount
setActiveAccount ( address : string ): void
The address of the account to set as active
Sets the active account for this wallet.
wallet . setActiveAccount ( 'ABCD...XYZ' )
signTransactions
abstract signTransactions < T extends algosdk . Transaction [] | Uint8Array [] > (
txnGroup : T | T [],
indexesToSign ?: number []
): Promise < ( Uint8Array | null )[] >
txnGroup
algosdk.Transaction[] | Uint8Array[]
required
Transaction or array of transactions to sign. Can be Transaction objects or encoded transactions
Optional array of indices indicating which transactions to sign. If not provided, the wallet will attempt to sign all transactions
Signs one or more transactions. Returns an array of signed transactions, with null for transactions that were not signed.
const signedTxns = await wallet . signTransactions ([ txn1 , txn2 ], [ 0 ])
// signedTxns[0] contains the signed first transaction
// signedTxns[1] is null (not signed)
transactionSigner
transactionSigner (
txnGroup : algosdk . Transaction [],
indexesToSign : number []
): Promise < Uint8Array [] >
txnGroup
algosdk.Transaction[]
required
Array of transactions to sign
Array of indices indicating which transactions to sign
Algorand SDK compatible transaction signer. Returns only the signed transactions (filters out nulls).
const atc = new algosdk . AtomicTransactionComposer ()
atc . addTransaction ({
txn: transaction ,
signer: wallet . transactionSigner
})
const result = await atc . execute ( algodClient , 4 )
signData
signData ( data : string , metadata : SignMetadata ): Promise < SignDataResponse >
The data to sign (base64 encoded)
Metadata about the signing request The scope of the signature (e.g., ScopeType.AUTH)
The encoding format (e.g., ‘base64’)
Signs arbitrary data. Only available if canSignData is true. Throws an error by default.
if ( wallet . canSignData ) {
const signature = await wallet . signData ( data , {
scope: ScopeType . AUTH ,
encoding: 'base64'
})
}
withPrivateKey
withPrivateKey < T >( callback : ( secretKey : Uint8Array ) => Promise < T > ): Promise < T >
callback
(secretKey: Uint8Array) => Promise<T>
required
Callback function that receives the private key
Provides temporary access to the wallet’s private key within a callback. Only available if canUsePrivateKey is true. The private key is automatically zeroed from memory after the callback completes. Throws an error by default.
if ( wallet . canUsePrivateKey ) {
const result = await wallet . withPrivateKey ( async ( secretKey ) => {
// Use the secret key
const signed = algosdk . signTransaction ( txn , secretKey )
return signed
})
// secretKey is automatically zeroed here
}
subscribe
subscribe ( callback : ( state : State ) => void ): () => void
callback
(state: State) => void
required
Function to call when state changes
Subscribes to state changes. Returns an unsubscribe function.
const unsubscribe = wallet . subscribe (( state ) => {
console . log ( 'Wallet state changed:' , state . wallets [ wallet . walletKey ])
})
// Later, to unsubscribe
unsubscribe ()
Wallet Implementations
The following wallet providers extend BaseWallet:
PeraWallet (WalletId.PERA) - Pera Wallet mobile and web
DeflyWallet (WalletId.DEFLY) - Defly Wallet mobile
DeflyWebWallet (WalletId.DEFLY_WEB) - Defly Wallet web extension
ExodusWallet (WalletId.EXODUS) - Exodus wallet
KibisisWallet (WalletId.KIBISIS) - Kibisis wallet
LuteWallet (WalletId.LUTE) - Lute wallet
BiatecWallet (WalletId.BIATEC) - Biatec wallet
W3Wallet (WalletId.W3_WALLET) - W3 wallet
WalletConnect (WalletId.WALLETCONNECT) - Generic WalletConnect integration
KmdWallet (WalletId.KMD) - Algorand Key Management Daemon
MnemonicWallet (WalletId.MNEMONIC) - Mnemonic-based wallet
Web3AuthWallet (WalletId.WEB3AUTH) - Web3Auth integration
MagicAuth (WalletId.MAGIC) - Magic authentication
CustomWallet (WalletId.CUSTOM) - Custom wallet implementation
Each implementation may accept specific options through the WalletManager configuration.