> ## 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.

# exportPrivateKey

> Exports the private key for a wallet

## Function Signature

```typescript theme={"system"}
exportPrivateKey(params: {
  walletMetadata: WalletMetadata;
  password?: string;
  externalServerKeyShares?: ServerKeyShare[];
}): Promise<string>
```

## Description

Exports the private key for the SVM wallet identified by the supplied `walletMetadata`. Returns a base58-encoded Solana keypair string.

<Warning>
  When you pass `externalServerKeyShares` (the caller-supplied path), `walletMetadata.externalServerKeySharesBackupInfo` must also be present — `exportPrivateKey` throws if shares are supplied but backup metadata is missing. The full `walletMetadata` returned from `createWalletAccount` / `importPrivateKey` already includes it; identity-only metadata from `fetchWalletMetadata` will be rejected.
</Warning>

## Parameters

### Required Parameters

* **`walletMetadata`** ([`WalletMetadata`](/node/reference/types/wallet-metadata)) - Non-sensitive wallet metadata persisted from `createWalletAccount()` / `importPrivateKey()`.

### Optional Parameters

* **`password`** (`string`) - Required if the wallet was created with `backUpToDynamic: true`.
* **`externalServerKeyShares`** ([`ServerKeyShare[]`](/node/reference/types/server-key-share)) - Caller-supplied plaintext shares.

## Returns

* **`Promise<string>`** - Base58-encoded Solana keypair

## Example

```typescript theme={"system"}
import { authenticatedSvmClient } from './client';

const svmClient = await authenticatedSvmClient();

const walletMetadata = JSON.parse(await redis.get(`wallet:${accountAddress}`));
const externalServerKeyShares = await vault.read(`wallet:${accountAddress}/shares`);

const privateKey = await svmClient.exportPrivateKey({
  walletMetadata,
  externalServerKeyShares,
  password: 'user-password',
});

console.log('Private key exported');
```

## Related

* [`WalletMetadata`](/node/reference/types/wallet-metadata) - The metadata object passed to every operation
* [`importPrivateKey()`](/node/reference/svm/import-private-key) - Import existing private key
