Skip to main content

Function Signature

Future<void> deleteKeychain()

Description

Removes all local wallet data from the device keychain. This deletes the signing shares stored locally.
After calling this method, the wallet will need to be recovered from backup to use again. Make sure the wallet is backed up before deleting the keychain.
On iOS, this method is a no-op (does nothing) as iOS doesn’t support programmatic keychain deletion in the same way.

Parameters

This method takes no parameters.

Returns

void

Example

import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

// First, ensure wallet is backed up
final isBackedUp = await portal.isWalletBackedUp();

if (isBackedUp) {
  // Safe to delete local data
  await portal.deleteKeychain();
  print('Local wallet data deleted');
} else {
  print('Please backup wallet before deleting');
}

Use Cases

Clear Data on Logout

Future<void> logout() async {
  final portal = Portal();

  // Ensure backup exists
  if (await portal.isWalletBackedUp()) {
    await portal.deleteKeychain();
  }

  // Clear other app data...
}

Reset Wallet

Future<void> resetWallet() async {
  final portal = Portal();

  // Delete local data
  await portal.deleteKeychain();

  // Create new wallet
  final addresses = await portal.createWallet();
  print('New wallet created: ${addresses.ethereum}');
}

Errors

CodeDescription
NOT_INITIALIZEDPortal was not initialized
DELETE_FAILEDFailed to delete keychain data