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

# Importing & exporting embedded wallet keys

> Import a raw private key into a WaaS wallet, or let users export their embedded wallet private keys in the Flutter SDK.

## Importing a private key

Use `wallets.waas.importPrivateKey` to import an existing raw private key into a Dynamic WaaS (MPC) wallet. The key is forwarded to the WaaS connector, which generates the MPC key shares for the wallet's chain. The connector is resolved from the supplied `chain`, so no wallet id is required, and the raw key never leaves the webview after the call returns.

```dart theme={"system"}
import 'package:dynamic_sdk/dynamic_sdk.dart';

Future<void> importKey(String privateKey) async {
  await DynamicSDK.instance.wallets.waas.importPrivateKey(
    chain: WaasChain.evm,
    privateKey: privateKey,
  );
}
```

### Parameters

<ParamField path="chain" type="WaasChain" required>
  The WaaS connector to import into: `WaasChain.evm`, `WaasChain.svm`, `WaasChain.btc`, `WaasChain.sui`, or `WaasChain.ton`.
</ParamField>

<ParamField path="privateKey" type="String" required>
  The raw private key to import.
</ParamField>

<ParamField path="thresholdSignatureScheme" type="ThresholdSignatureScheme">
  Optionally override the signature scheme: `twoOfTwo` (default), `twoOfThree`, or `threeOfFive`.
</ParamField>

<ParamField path="addressType" type="BtcAddressType">
  Bitcoin address type — `nativeSegwit` or `taproot`. Required when `chain` is `WaasChain.btc`; ignored for other chains.
</ParamField>

<ParamField path="publicAddressCheck" type="String">
  Optionally assert the resulting public address. The import is rejected when the derived address does not match.
</ParamField>

<ParamField path="password" type="String">
  Optionally password-protect the newly created WaaS wallet. This does not unlock an existing wallet.
</ParamField>

### Importing a Bitcoin key

When importing into `WaasChain.btc`, an `addressType` is required:

```dart theme={"system"}
await DynamicSDK.instance.wallets.waas.importPrivateKey(
  chain: WaasChain.btc,
  privateKey: privateKey,
  addressType: BtcAddressType.nativeSegwit,
);
```

## Exporting embedded wallet keys

Dynamic allows users to export their embedded wallet private keys for maximum control and portability. During export:

1. The key shares are temporarily recombined on the user's device using secure MPC
2. The private key is constructed client-side and provided to the user

This ensures users maintain true self-custody and can always access their assets, even outside of Dynamic's ecosystem.

<Note>
  When implementing Dynamic in a custom UI, ensure you surface this flow to your end-users so they always maintain control of their wallet.
</Note>

## Private key export settings

By default, users can export their private keys from embedded wallets. You can control this setting in the [Embedded Wallets dashboard](https://app.dynamic.xyz/dashboard/embedded-wallets/dynamic). Navigate to the **Security** section and toggle **Private Key Exports** to enable or disable private key exports.

<Frame>
  <img src="https://mintcdn.com/dynamic-docs/tU4QJtnK1LxWeTz7/images/dashboard/dashboard-private-key-export-toggle.png?fit=max&auto=format&n=tU4QJtnK1LxWeTz7&q=85&s=525fb8534ae79260f8130e8c7707a348" alt="Private Key Export Toggle" width="2152" height="210" data-path="images/dashboard/dashboard-private-key-export-toggle.png" />
</Frame>

<Warning>
  Consider disabling private key exports if your use case requires additional security controls. Disabling exports prevents users from exporting keys, which can reduce the risk of key exposure but limits user portability. See [Best Practices - Private Key Export Controls](/docs/overview/security/recommendedpaths#private-key-export-controls) for guidance.
</Warning>

## Revealing the private key

To open the export wallet flow on behalf of your users, call `revealEmbeddedWalletPrivateKey()` on the SDK's UI module. This presents a secure flow where only the end-user can see their private key.

```dart theme={"system"}
final sdk = DynamicSDK.instance;

sdk.ui.revealEmbeddedWalletPrivateKey();
```

### Example

```dart theme={"system"}
import 'package:dynamic_sdk/dynamic_sdk.dart';
import 'package:flutter/material.dart';

class RevealPrivateKeyButton extends StatelessWidget {
  const RevealPrivateKeyButton({super.key});

  @override
  Widget build(BuildContext context) {
    return ElevatedButton(
      onPressed: () {
        final sdk = DynamicSDK.instance;
        sdk.ui.revealEmbeddedWalletPrivateKey();
      },
      child: const Text('Reveal Private Key'),
    );
  }
}
```

<Warning>
  You should always provide your end-users with a path to reveal and replicate their keys from their embedded wallet. When using a custom UI embedded wallet flow, ensure you add a path for users to complete this step using the method described above.
</Warning>

End-users should be aware that replicating their wallet credentials can expose their wallet to risk if the credentials are not stored securely. Users are advised to store their credentials in a secure location and not share them with anyone. When implementing Dynamic in a custom UI, we recommend communicating these warnings to users.
