Skip to main content
Privy enables your users to export the private key for their embedded wallet. This allows them to use their embedded wallet address with another wallet client, such as MetaMask or Phantom.

Availability

Key export is only available in certain environments depending on how the wallet was created.

Supported chains

Key export is available for all wallets on Tier 2 and Tier 3 chains.

Usage

To have your user export their embedded wallet’s private key, use Privy’s exportWallet method:
import {usePrivy} from '@privy-io/react-auth';
...
const {exportWallet} = usePrivy();
When invoked, exportWallet will open a modal where your user can copy the full private key for their embedded wallet. The modal will also link your user to a guide for how to load their embedded wallet into another wallet client, such as MetaMask or Phantom.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 exportWallet to an export wallet button in your app:
import {usePrivy} from '@privy-io/react-auth';

function ExportWalletButton() {
  const {ready, authenticated, user, exportWallet} = usePrivy();
  // Check that your user is authenticated
  const isAuthenticated = ready && authenticated;
  // Check that your user has an embedded wallet
  const hasEmbeddedWallet = !!user.linkedAccounts.find(
    (account) =>
      account.type === 'wallet' &&
      account.walletClientType === 'privy' &&
      account.chainType === 'ethereum'
  );

  return (
    <button onClick={exportWallet} disabled={!isAuthenticated || !hasEmbeddedWallet}>
      Export my wallet
    </button>
  );
}
If your application uses smart wallets on EVM networks, exporting the wallet will export the private key for the smart wallet’s signer, and not the smart wallet itself. Users can control their smart wallet via this private key, but will be required to manually use it to sign calls to the contract for their smart wallet directly to use the smart wallet outside of your app.

Exporting HD wallets

If your user has multiple embedded wallets, you can export the private key for a specific wallet by passing the address of your desired wallet as an address parameter to the exportWallet method:
import {exportWallet} from '@privy-io/react-auth';
...
const {exportWallet} = usePrivy();
await exportWallet({address: 'insert-your-desired-address'});
When your user exports their embedded wallet, their private key is assembled on a different origin than your app’s origin. This means neither you nor Privy can ever access your user’s private key. Your user is the only party that can ever access their full private key.

Private key formats

The format of the exported private key varies depending on the chain type of the wallet:
ChainFormatExample
EthereumHex0x...
SolanaBase585K...
SparkMnemonicword1 word2 word3 ...
NEARed25519: prefixeded25519:...
Suisuiprivkey bech32suiprivkey...
BitcoinWIFKwDi...
All othersHex0x...