> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://www.openfort.io/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

# Export Private Key

This allows them to use their embedded wallets address with another wallet client, such as Metamask in any application.
If the wallet is a Smart Account, note that the exported key only controls the smart account and doesn't hold its assets. If you want to simply transfer ownership to a Metamask and interact with a smart contract, we'll recommend checking the [smart wallet section](https://www.openfort.io/docs/products/embedded-wallet/javascript/smart-wallet/).

To have your user export their embedded wallet's private key, use the `exportPrivateKey` method from the SDK.

If your user is not `authenticated` or has not yet created an embedded wallet in your app, this method will fail.

As an example, you might attach `exportPrivateKey` as an event handler to an export wallet button in your app:

:::code-group
```tsx [ExportWalletButton.tsx]
import openfort from "./openfortConfig"

// This example assumes you have already checked that Openfort 'embeddedState' is 
// `ready` and the user is `authenticated`
function ExportWalletButton() {
  const handleExportWalletButton = async () => {
    const privateKey = await openfort.embeddedWallet.exportPrivateKey();
    console.log(privateKey);
  };

  return (
      <button onClick={handleExportWalletButton}>
        {'Export my wallet'}
      </button>
  );
}
```

```ts [openfortConfig.ts]
import { Openfort } from '@openfort/openfort-js';

const openfort = new Openfort({
  baseConfiguration: {
    publishableKey: "YOUR_OPENFORT_PUBLISHABLE_KEY",
  },
  shieldConfiguration: {
    shieldPublishableKey: "YOUR_SHIELD_PUBLISHABLE_KEY",
  },
});
export default openfort;
```
:::

:::info
When your user exports their embedded wallet, their private key is assembled inside the embedded wallet iframe, on a different origin than your app's origin. `exportPrivateKey` then returns the full private key to your app's code, so treat it as sensitive and show it only to the user.
:::
