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

reshare(params: {
  chainName: string;
  accountAddress: string;
  oldThresholdSignatureScheme: ThresholdSignatureScheme;
  newThresholdSignatureScheme: ThresholdSignatureScheme;
  walletMetadata: WalletMetadata;
  password?: string;
  externalServerKeyShares?: ServerKeyShare[];
  backUpToDynamic?: boolean;
}): Promise<{
  externalServerKeyShares: ServerKeyShare[];
  backupInfo: KeyShareBackupInfo;
}>

Description

Reshares a wallet with a new threshold signature scheme (e.g. 2-of-2 → 2-of-3). Returns the new shares plus an updated backupInfo. Re-cache the backupInfo and the new thresholdSignatureScheme into your stored walletMetadata.

Parameters

Required Parameters

  • chainName (string) - The chain name (e.g., 'SVM')
  • accountAddress (string) - The wallet address. Must match walletMetadata.accountAddress.
  • oldThresholdSignatureScheme (ThresholdSignatureScheme) - The current threshold scheme
  • newThresholdSignatureScheme (ThresholdSignatureScheme) - The new threshold scheme
  • 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 up the new shares.

Returns

  • Promise<{ externalServerKeyShares, backupInfo }>
    • externalServerKeyShares — The new shares under the new threshold scheme.
    • backupInfo (KeyShareBackupInfo) — Updated backup-pointer state.

Example

import { authenticatedSvmClient } from './client';
import { ThresholdSignatureScheme } from '@dynamic-labs-wallet/node';

const svmClient = await authenticatedSvmClient();

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

const { externalServerKeyShares: newShares, backupInfo } = await svmClient.reshare({
  chainName: 'SVM',
  accountAddress,
  oldThresholdSignatureScheme: ThresholdSignatureScheme.TWO_OF_TWO,
  newThresholdSignatureScheme: ThresholdSignatureScheme.TWO_OF_THREE,
  walletMetadata,
  externalServerKeyShares,
  password: 'user-password',
  backUpToDynamic: true,
});

const updatedMetadata = {
  ...walletMetadata,
  thresholdSignatureScheme: ThresholdSignatureScheme.TWO_OF_THREE,
  externalServerKeySharesBackupInfo: backupInfo,
};
await redis.set(`wallet:${accountAddress}`, JSON.stringify(updatedMetadata));
await vault.write(`wallet:${accountAddress}/shares`, newShares);