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

exportKey(params: {
  accountAddress: string;
  chainName: string;
  walletMetadata: WalletMetadata;
  externalServerKeyShares?: ServerKeyShare[];
  password?: string;
}): Promise<{ derivedPrivateKey: string }>

Description

Exports a key for the wallet identified by walletMetadata. This is the base-class operation that exportPrivateKey() builds on; most callers should use exportPrivateKey() directly.
When you pass externalServerKeyShares (the caller-supplied path), walletMetadata.externalServerKeySharesBackupInfo must also be present — exportKey throws if shares are supplied but backup metadata is missing. The full walletMetadata returned from createWalletAccount / importPrivateKey already includes it; identity-only metadata from fetchWalletMetadata will be rejected.

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

  • externalServerKeyShares (ServerKeyShare[]) - Caller-supplied plaintext shares.
  • password (string) - Required if the wallet was created with backUpToDynamic: true.

Returns

  • Promise<{ derivedPrivateKey: string }> - The derived private key

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 { derivedPrivateKey } = await svmClient.exportKey({
  accountAddress,
  chainName: 'SVM',
  walletMetadata,
  externalServerKeyShares,
  password: 'user-password',
});