Skip to main content

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.

Function Signature

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. You must re-cache the backupInfo into your stored walletMetadata.externalServerKeySharesBackupInfo.

Parameters

Required Parameters

  • accountAddress (string) - The wallet address. Must match walletMetadata.accountAddress.
  • chainName (string) - The chain name (e.g., 'SVM')
  • walletMetadata (WalletMetadata) - The cached metadata for this wallet

Optional Parameters

  • password (string) - Required when backUpToDynamic is true.
  • externalServerKeyShares (ServerKeyShare[]) - Current plaintext shares.
  • backUpToDynamic (boolean) - Whether to back the new shares up to Dynamic.

Returns

  • Promise<{ externalServerKeyShares, backupInfo }>
    • externalServerKeyShares — The newly-generated shares. Re-vault these.
    • backupInfo (KeyShareBackupInfo) — Updated backup-pointer state. Merge into cached walletMetadata.

Example

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 { externalServerKeyShares: refreshedShares, backupInfo } =
  await svmClient.refreshWalletAccountShares({
    accountAddress,
    chainName: 'SVM',
    walletMetadata,
    externalServerKeyShares,
    password: 'user-password',
    backUpToDynamic: true,
  });

const updatedMetadata = {
  ...walletMetadata,
  externalServerKeySharesBackupInfo: backupInfo,
};
await redis.set(`wallet:${accountAddress}`, JSON.stringify(updatedMetadata));
await vault.write(`wallet:${accountAddress}/shares`, refreshedShares);
  • WalletMetadata - The metadata object passed to every operation
  • reshare() - Change threshold scheme + refresh shares in one call