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

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 per-share backup status and an updated backupInfomerge backupInfo into your cached walletMetadata.externalServerKeySharesBackupInfo.

Parameters

Required Parameters

  • accountAddress (string) - The wallet address. Must match walletMetadata.accountAddress.
  • walletMetadata (WalletMetadata) - The cached metadata for this wallet
  • externalServerKeyShares (ServerKeyShare[]) - Plaintext shares to back up
  • backUpToDynamic (boolean) - Whether to back the shares up to Dynamic

Optional Parameters

  • password (string) - Required when backUpToDynamic is true

Returns

  • Promise<object> - { keySharesWithBackupStatus, backupInfo }. Merge backupInfo 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 { backupInfo } = await svmClient.storeEncryptedBackupByWallet({
  accountAddress,
  walletMetadata,
  externalServerKeyShares,
  password: 'user-password',
  backUpToDynamic: true,
});

const updated = { ...walletMetadata, externalServerKeySharesBackupInfo: backupInfo };
await redis.set(`wallet:${accountAddress}`, JSON.stringify(updated));