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

# storeEncryptedBackupByWallet

> Stores encrypted backup for a wallet using external server key shares

## Function Signature

```typescript theme={"system"}
storeEncryptedBackupByWallet(params: {
  accountAddress: string;
  walletMetadata: WalletMetadata;
  externalServerKeyShares: ServerKeyShare[];
  password?: string;
  backUpToDynamic: boolean;
}): Promise<{
  keySharesWithBackupStatus: Array<{
    share: ServerKeyShare;
    backedUpToClientKeyShareService: boolean;
  }>;
  backupInfo: KeyShareBackupInfo;
}>
```

## Description

Stores encrypted backup for a wallet's external server key shares on Dynamic's key share service. Returns the per-share backup status and an updated `backupInfo` — **merge `backupInfo` into your cached `walletMetadata.externalServerKeySharesBackupInfo`** to keep it consistent.

## Parameters

### Required Parameters

* **`accountAddress`** (`string`) - The wallet address (must include `0x` prefix). Must match `walletMetadata.accountAddress`.
* **`walletMetadata`** ([`WalletMetadata`](/node/reference/types/wallet-metadata)) - The cached metadata for this wallet
* **`externalServerKeyShares`** ([`ServerKeyShare[]`](/node/reference/types/server-key-share)) - Plaintext shares to back up
* **`backUpToDynamic`** (`boolean`) - Whether to back the shares up to Dynamic's key share service

### Optional Parameters

* **`password`** (`string`) - Required when `backUpToDynamic` is `true`; used to encrypt the backup

## Returns

* **`Promise<object>`**
  * `keySharesWithBackupStatus` — per-share backup status
  * `backupInfo` ([`KeyShareBackupInfo`](/node/reference/types/key-share-backup-info)) — updated backup-pointer state; merge into cached `walletMetadata`.

## Example

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

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

const { keySharesWithBackupStatus, backupInfo } = await evmClient.storeEncryptedBackupByWallet({
  accountAddress,
  walletMetadata,
  externalServerKeyShares,
  password: 'user-password',
  backUpToDynamic: true,
});

// Re-cache the updated metadata.
const updated = { ...walletMetadata, externalServerKeySharesBackupInfo: backupInfo };
await redis.set(`wallet:${accountAddress}`, JSON.stringify(updated));
```

## Related

* [`WalletMetadata`](/node/reference/types/wallet-metadata) - The metadata object passed to every operation
* [`storeEncryptedBackupByWalletWithRetry()`](/node/reference/evm/store-encrypted-backup-by-wallet-with-retry) - Store backup with automatic retry on transient failures
* [`recoverEncryptedBackupByWallet()`](/node/reference/evm/recover-encrypted-backup-by-wallet) - Recover encrypted backup
