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

# refreshWalletAccountShares

> Refreshes wallet account shares for a specific wallet

## Function Signature

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

## Description

Refreshes the wallet's MPC key shares while maintaining the same threshold signature scheme. Returns both the new `externalServerKeyShares` and an updated `backupInfo` reflecting the new backup state. **You must re-cache the `backupInfo`** into your stored `walletMetadata.externalServerKeySharesBackupInfo` — otherwise subsequent operations read stale metadata.

## Parameters

### Required Parameters

* **`accountAddress`** (`string`) - The wallet address (must include `0x` prefix). Must match `walletMetadata.accountAddress`.
* **`chainName`** (`string`) - The chain name (e.g., `'EVM'`)
* **`walletMetadata`** ([`WalletMetadata`](/node/reference/types/wallet-metadata)) - The cached metadata for this wallet

### Optional Parameters

* **`password`** (`string`) - **Required when `backUpToDynamic` is `true`.** Used to encrypt the refreshed shares for Dynamic-managed backup.
* **`externalServerKeyShares`** ([`ServerKeyShare[]`](/node/reference/types/server-key-share)) - Current plaintext shares. If omitted, the SDK recovers from backup using `password`.
* **`backUpToDynamic`** (`boolean`) - Whether to back the new shares up to Dynamic's key share service. Defaults to `false`.

## Returns

* **`Promise<{ externalServerKeyShares, backupInfo }>`**
  * `externalServerKeyShares` — The newly-generated shares. Re-vault these; the old shares no longer sign with this wallet.
  * `backupInfo` ([`KeyShareBackupInfo`](/node/reference/types/key-share-backup-info)) — Updated backup-pointer state. Merge into your 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 { externalServerKeyShares: refreshedShares, backupInfo } =
  await evmClient.refreshWalletAccountShares({
    accountAddress,
    chainName: 'EVM',
    walletMetadata,
    externalServerKeyShares,
    password: 'user-password',
    backUpToDynamic: true,
  });

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

## Error Handling

```typescript theme={"system"}
try {
  const result = await evmClient.refreshWalletAccountShares({
    accountAddress,
    chainName: 'EVM',
    walletMetadata,
    externalServerKeyShares,
    password: 'user-password',
    backUpToDynamic: true,
  });
  console.log('Wallet shares refreshed successfully');
} catch (error) {
  console.error('Failed to refresh wallet shares:', error);
}
```

## Related

* [`WalletMetadata`](/node/reference/types/wallet-metadata) - The metadata object passed to every operation
* [`reshare()`](/node/reference/evm/reshare) - Change threshold scheme + refresh shares in one call
* [Storage Best Practices](/node/wallets/server-wallets/storage-best-practices) - Where to cache metadata vs. vault shares
