Guide
Manage wallet lifecycle states
Users can have multiple states in their wallet lifecycle: having a wallet, having wallet backups, having certain recovery methods available, and more.
Was this page helpful?
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Users can have multiple states in their wallet lifecycle: having a wallet, having wallet backups, having certain recovery methods available, and more.
// Checks if the user has created a wallet on any device.
await portal.doesWalletExist()
// Checks if the user's wallet share is on their current device.
await portal.isWalletOnDevice()
// Checks if the user has backed up their wallet.
await portal.isWalletBackedUp()
// Checks if the user can recover their wallet.
await portal.isWalletRecoverable()
// Returns a list of available recovery methods based on the user's backups.
await portal.availableRecoveryMethods()
async function manageWalletState(): Promise<void> {
try {
// Determine the wallet's state.
const walletExists = await portal.doesWalletExist();
const walletExistsOnDevice = await portal.isWalletOnDevice();
const walletIsRecoverable = await portal.isWalletRecoverable();
if (!walletExists) {
// Create and back up the wallet using portal.createWallet() and portal.backup().
} else if (!walletExistsOnDevice) {
if (walletIsRecoverable) {
// Recover the wallet using portal.recover().
} else {
// Inform the user to back up the wallet on the original device.
}
} else {
// The wallet is ready to use.
}
} catch (error) {
// Handle any errors that occur.
}
}
Was this page helpful?