Formatting

Chain✅ Import Format✅ Export Format
EVMHexadecimal with or without 0xHexadecimal without 0x
SolanaBase58-encoded private keyBase58-encoded private key
SuiBech32-encoded private keyBech32-encoded private key

Importing External Keys

When importing an existing private key into Dynamic’s TSS-MPC system, we use Shamir Secret Sharing (SSS) to securely split the key into multiple shares. This process:

  1. Takes your existing private key as input
  2. Uses SSS to split it into either 2 or 3 shares (depending on your configuration)
  3. Distributes the shares between the relevant parties (user, server, and optionally a backup)
  4. Securely destroys the original private key

After import, the key exists solely in its distributed form, and all future operations are performed using TSS-MPC. The complete private key is never reconstructed, preserving the security benefits of TSS-MPC while enabling seamless migration from traditional wallets.

Import Functions

importPrivateKey(options)

Imports a private key. Available from the useDynamicWaas hook.

Parameters:

  • privateKey: string - The private key to import
  • thresholdSignatureScheme: string - Defaults to ‘TWO_OF_TWO’
import { useDynamicWaas } from "@dynamic-labs/sdk-react-core";

const { importPrivateKey } = useDynamicWaas();

const privateKeyInput = "0x...";

await importPrivateKey({
  chainName: "EVM",
  privateKey: privateKeyInput,
});

Exporting Keys

Key export should be treated with caution as it temporarily reconstructs the complete private key. We recommend using the MPC system for normal operations and only exporting when absolutely necessary.

For maximum user control and portability, Dynamic allows users to export their private keys. 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.

When implementing Dynamic in headless mode, please ensure you are surfacing this flow to your end-users, so that they always maintain control of their wallet.

End-User Experience

The Dynamic export flow reveals the private key/seed phrase in an secure isolated iFrame to limit the ability of Dynamic, the developer, or anyone in the flow to view the exported key. For more details on the security of the iframe and cryptographic flows go to our FAQs.

Programmatically Triggering Wallet Export Flow

To open the export wallet flow on behalf of your users, you can call the initExportProcess method from the useEmbeddedReveal hook. This will open the flow described above. Only the end-user will be able to see the private key or seed phrase.

import { useEmbeddedReveal } from "@dynamic-labs/sdk-react-core";

const { initExportProcess } = useEmbeddedReveal();

<button onClick={() => initExportProcess()}>Export Wallet</button>;

You can see the experience by going to demo.dynamic.xyz and creating an embedded wallet.

Export Functions

You can also trigger export flows programmatically using the wallet connector.

exportPrivateKey(options)

Exports the private key for a specific account. Available from the wallet connector.

Parameters:

  • accountAddress: string - The address of the account to export
  • displayContainer: HTMLIFrameElement - The container to display the private key in
import { useDynamicContext } from "@dynamic-labs/sdk-react-core";

const { primaryWallet } = useDynamicContext();

const handleExportPrivateKey = async () => {
  if (!primaryWallet?.address) {
    setErrorMessage("Please create a wallet first");
    return;
  }

  const connector = primaryWallet?.connector as DynamicWaasEVMConnector;
  const privateKey = await connector.exportPrivateKey({
    accountAddress: primaryWallet?.address,
    displayContainer: document.createElement('iframe'), // Replace with your secure container
  });
};

exportClientKeyshares(options)

Exports client keyshares for a specific account. Available from the wallet connector.

Parameters:

  • accountAddress: string - The address of the account to export keyshares for
import { useDynamicContext } from "@dynamic-labs/sdk-react-core";

const { primaryWallet } = useDynamicContext();

const handleExportKeyShares = async () => {
  if (!primaryWallet?.address) {
    setErrorMessage("Please create a wallet first");
    return;
  }

  const connector = primaryWallet?.connector as DynamicWaasEVMConnector;
  const keyShares = await connector.exportClientKeyshares({
    accountAddress: primaryWallet?.address,
  });
};

You should always provide your end-users with a path to reveal and replicate their keys from their embedded wallet. When using the headless embedded wallet flow, please ensure you add a path for users to complete this step using the programmatic option described above.

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 headless mode, we recommend communicating these warnings to users.