If a user loses their device or needs to access their wallet on a new device, they can recover it using their backup.
Recovery Process
The recovery process requires:
- The backup method that was originally used
- The authentication credentials (password, passkey, or cloud storage access)
Recovery Methods
Password Recovery
If the wallet was backed up with a password:
import 'package:portal_flutter/portal_flutter.dart';
final portal = Portal();
// Recover wallet with password
final addresses = await portal.recoverWallet(
method: PortalBackupMethod.password,
password: 'THE-USER-PASSWORD',
);
print('Wallet recovered!');
print('EVM address: ${addresses.ethereum}');
print('Solana address: ${addresses.solana}');
Passkey Recovery
If the wallet was backed up with a passkey:
import 'package:portal_flutter/portal_flutter.dart';
final portal = Portal();
// Configure passkey storage first
await portal.configurePasskeyStorage(
relyingPartyId: 'portalhq.io',
relyingPartyOrigins: ['https://portalhq.io'],
);
// Recover wallet with passkey
final addresses = await portal.recoverWallet(
method: PortalBackupMethod.passkey,
);
print('Wallet recovered!');
Google Drive Recovery
If the wallet was backed up to Google Drive:
import 'package:portal_flutter/portal_flutter.dart';
final portal = Portal();
// Configure Google Drive storage first
await portal.configureGoogleStorage(
clientId: 'your-google-client-id',
);
// Recover wallet with Google Drive
final addresses = await portal.recoverWallet(
method: PortalBackupMethod.googleDrive,
);
print('Wallet recovered!');
iCloud Recovery (iOS only)
If the wallet was backed up to iCloud:
import 'package:portal_flutter/portal_flutter.dart';
final portal = Portal();
// Configure iCloud storage first
await portal.configureICloudStorage();
// Recover wallet with iCloud
final addresses = await portal.recoverWallet(
method: PortalBackupMethod.iCloud,
);
print('Wallet recovered!');
Checking Recovery Status
Before attempting recovery, you can check if a wallet is recoverable:
// Check if wallet can be recovered
final isRecoverable = await portal.isWalletRecoverable();
if (isRecoverable) {
// Get available recovery methods
final methods = await portal.availableRecoveryMethods();
print('Available recovery methods: $methods');
} else {
print('No recovery options available');
}
Check Password Recovery Availability
If you want to specifically check if password recovery is available:
final canRecoverWithPassword = await portal.isPasswordRecoverAvailable();
if (canRecoverWithPassword) {
print('Password recovery is available');
}
If a user forgets their password and has no other backup method configured, there is no way to recover the wallet. Always recommend users set up multiple backup methods.
Related Documentation