> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# deleteKeychain

> Delete local keychain data.

## Function Signature

```dart theme={null}
Future<void> deleteKeychain()
```

## Description

Removes all local wallet data from the device keychain. This deletes the signing shares stored locally.

<Warning>
  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.
</Warning>

<Note>
  On iOS, this method is a no-op (does nothing) as iOS doesn't support programmatic keychain deletion in the same way.
</Note>

## Parameters

This method takes no parameters.

## Returns

**`void`**

## Example

```dart theme={null}
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

```dart theme={null}
Future<void> logout() async {
  final portal = Portal();

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

  // Clear other app data...
}
```

### Reset Wallet

```dart theme={null}
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

| Code              | Description                    |
| ----------------- | ------------------------------ |
| `NOT_INITIALIZED` | Portal was not initialized     |
| `DELETE_FAILED`   | Failed to delete keychain data |

## Related

* [recoverWallet](./recoverwallet)
* [isWalletBackedUp](./iswalletbackedup)
