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

exportPrivateKey(params: {
  walletMetadata: WalletMetadata;
  password?: string;
  externalServerKeyShares?: ServerKeyShare[];
}): Promise<string>

Description

Exports the private key for the SVM wallet identified by the supplied walletMetadata. Returns a base58-encoded Solana keypair string.
When you pass externalServerKeyShares (the caller-supplied path), walletMetadata.externalServerKeySharesBackupInfo must also be present — exportPrivateKey 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

  • walletMetadata (WalletMetadata) - Non-sensitive wallet metadata persisted from createWalletAccount() / importPrivateKey().

Optional Parameters

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

Returns

  • Promise<string> - Base58-encoded Solana keypair

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 privateKey = await svmClient.exportPrivateKey({
  walletMetadata,
  externalServerKeyShares,
  password: 'user-password',
});

console.log('Private key exported');