Skip to main content

Function Signature

Future<PortalAddresses> recoverWallet({
  required PortalBackupMethod method,
  String? password,
  String? cipherText,
})

Description

Recovers a wallet from a backup using the specified backup method. This is used when a user needs to access their wallet on a new device.

Parameters

ParameterTypeRequiredDescription
methodPortalBackupMethodYesThe backup method that was used
passwordStringNoRequired when recovering with PortalBackupMethod.password
cipherTextStringNoThe encrypted backup data (for self-managed backups)

Returns

PortalAddresses - An object containing the recovered wallet addresses:
PropertyTypeDescription
ethereumString?The Ethereum/EVM address
solanaString?The Solana address

Example

import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

// Recover with password
final addresses = await portal.recoverWallet(
  method: PortalBackupMethod.password,
  password: 'user-password',
);

print('Recovered EVM address: ${addresses.ethereum}');
print('Recovered Solana address: ${addresses.solana}');

Self-Managed Backup Recovery

// Recover with cipher text (self-managed backups)
final addresses = await portal.recoverWallet(
  method: PortalBackupMethod.password,
  password: 'user-password',
  cipherText: 'stored-cipher-text',
);

Errors

CodeDescription
NOT_INITIALIZEDPortal was not initialized
RECOVERY_FAILEDThe recovery operation failed
INVALID_PASSWORDThe provided password is incorrect
BACKUP_NOT_FOUNDNo backup found for the specified method