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

# importPrivateKey

> Imports an existing SVM private key into the MPC wallet system

## Function Signature

```typescript theme={"system"}
importPrivateKey(params: {
  privateKey: string;
  chainName: string;
  thresholdSignatureScheme: ThresholdSignatureScheme;
  password?: string;
  onError?: (error: Error) => void;
  backUpToDynamic?: boolean;
}): Promise<{
  walletMetadata: WalletMetadata;
  rawPublicKey: string;
  externalServerKeyShares: ServerKeyShare[];
  externalKeySharesWithBackupStatus: Array<{
    share: ServerKeyShare;
    backedUpToClientKeyShareService: boolean;
  }>;
}>
```

## Description

Imports an existing Solana private key into the MPC wallet system. The private key is split into shares according to the specified threshold signature scheme. Returns a [`walletMetadata`](/node/reference/types/wallet-metadata) object (non-sensitive identity + backup pointers) alongside the sensitive `externalServerKeyShares`. **Persist both** — `walletMetadata` in your cache and `externalServerKeyShares` in a secrets vault.

## Parameters

### Required Parameters

* **`privateKey`** (`string`) - The private key to import
* **`chainName`** (`string`) - The chain name (use `'SVM'` for Solana)
* **`thresholdSignatureScheme`** (`ThresholdSignatureScheme`) - The threshold signature scheme

### Optional Parameters

* **`password`** (`string`) - **Required when `backUpToDynamic` is `true`.**
* **`onError`** (`(error: Error) => void`) - Error callback function
* **`backUpToDynamic`** (`boolean`) - Whether to back up the first key share to Dynamic. **When `true`, a `password` must be provided.**

## Returns

* **`Promise<object>`** - Object containing wallet information:
  * `walletMetadata` ([`WalletMetadata`](/node/reference/types/wallet-metadata)) - Persist in cache.
  * `rawPublicKey` - Raw public key
  * `externalServerKeyShares` ([`ServerKeyShare[]`](/node/reference/types/server-key-share)) - Store in secrets vault.
  * `externalKeySharesWithBackupStatus` - Array of key shares with their backup status

## Example

```typescript theme={"system"}
import { authenticatedSvmClient } from './client';
import { ThresholdSignatureScheme } from '@dynamic-labs-wallet/node';

const svmClient = await authenticatedSvmClient();

const { walletMetadata, externalServerKeyShares } = await svmClient.importPrivateKey({
  privateKey: 'YourSolanaPrivateKey',
  chainName: 'SVM',
  thresholdSignatureScheme: ThresholdSignatureScheme.TWO_OF_TWO,
  password: 'your-password',
  backUpToDynamic: true,
});

console.log('Wallet imported:', walletMetadata.accountAddress);

await redis.set(`wallet:${walletMetadata.accountAddress}`, JSON.stringify(walletMetadata));
await vault.write(`wallet:${walletMetadata.accountAddress}/shares`, externalServerKeyShares);
```

## Related

* [`WalletMetadata`](/node/reference/types/wallet-metadata) - The metadata object passed to every operation
* [`createWalletAccount()`](/node/reference/svm/create-wallet-account) - Create a new wallet
* [`exportPrivateKey()`](/node/reference/svm/export-private-key) - Export private key
