Function Signature

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

Description

Exports a key for a specific chain using external server key shares. This function reconstructs the key from distributed key shares for the specified blockchain network.

Parameters

Required Parameters

  • accountAddress (string) - The wallet address to export key for (must include 0x prefix)
  • externalServerKeyShares (any[]) - Array of external server key shares
  • chainName (string) - The name of the blockchain chain (e.g., ‘base-sepolia’)

Optional Parameters

  • password (string) - Wallet password (if wallet is password-protected)

Returns

  • Promise<string> - The exported key as a hex string

Example

import { authenticatedEvmClient } from './client';

const evmClient = await authenticatedEvmClient();

const exportedKey = await evmClient.exportKey({
  accountAddress: '0xYourWalletAddress',
  externalServerKeyShares: [
    {
      chainName: 'base-sepolia',
      keyShare: '0x1234567890',
    },
  ],
  password: 'optional-password',
  chainName: 'base-sepolia',
});

console.log('Key exported:', exportedKey);

Key Share Format

interface KeyShare {
  chainName: string;
  keyShare: string;
}

const externalServerKeyShares: KeyShare[] = [
  {
    chainName: 'base-sepolia', // or your specific chain
    keyShare: '0x1234567890', // the actual key share
  },
];

Error Handling

try {
  const exportedKey = await evmClient.exportKey({
    accountAddress: '0xYourWalletAddress',
    externalServerKeyShares,
    chainName: 'base-sepolia',
  });
  console.log('Key exported successfully');
} catch (error) {
  console.error('Failed to export key:', error);
}