Function Signature

exportPrivateKey(params: {
  accountAddress: string;
  externalServerKeyShares: any[];
  password: string;
}): Promise<string>

Description

Exports the private key for a wallet. This function requires external server key shares and a valid password for security.

Parameters

Required Parameters

  • accountAddress (string) - The wallet address to export private key for
  • externalServerKeyShares (any[]) - Array of external server key shares
  • password (string) - Wallet password for security

Returns

  • Promise<string> - The exported private key

Example

import { authenticatedSvmClient } from './client';

const svmClient = await authenticatedSvmClient();

const privateKey = await svmClient.exportPrivateKey({
  accountAddress: 'YourSolanaWalletAddress',
  externalServerKeyShares: [
    {
      chainName: 'solana',
      keyShare: '0xYourKeyShare',
    },
  ],
  password: 'your-password',
});

console.log('Private Key:', privateKey);

Error Handling

try {
  const privateKey = await svmClient.exportPrivateKey({
    accountAddress: 'YourSolanaWalletAddress',
    externalServerKeyShares,
    password: 'your-password',
  });
  console.log('Private key exported successfully');
} catch (error) {
  console.error('Failed to export private key:', error);
}