Skip to main content

Function Signature

createWalletAccount(params: {
  thresholdSignatureScheme: ThresholdSignatureScheme;
  password?: string;
  onError?: (error: Error) => void;
  backUpToClientShareService?: boolean;
}): Promise<{
  accountAddress: string;
  publicKeyHex: string;
  rawPublicKey: EcdsaPublicKey | Uint8Array | string | undefined;
  /** @deprecated Use externalKeySharesWithBackupStatus instead */
  externalServerKeyShares: ServerKeyShare[];
  externalKeySharesWithBackupStatus: Array<{
    share: ServerKeyShare;
    backedUpToClientKeyShareService: boolean;
  }>;
  walletId: string;
}>

Description

Creates a new EVM wallet account with the specified threshold signature scheme. Returns wallet information including the account address, public keys, and key shares with their backup status.

Parameters

Required Parameters

  • thresholdSignatureScheme (ThresholdSignatureScheme) - The threshold signature scheme for the wallet

Optional Parameters

  • password (string) - Wallet password for additional security
  • onError ((error: Error) => void) - Error callback function
  • backUpToClientShareService (boolean) - Whether to back up the first key share to Dynamic’s client share service (defaults to false). When true, the first share is backed up to Dynamic and the remaining shares are returned for external storage. When false, all shares are returned for external storage.

Returns

  • Promise<object> - Object containing wallet information:
    • accountAddress - The wallet’s account address
    • publicKeyHex - Public key in hex format
    • rawPublicKey - Raw public key object
    • externalKeySharesWithBackupStatus - Array of key shares with their backup status. Each entry contains:
      • share - The key share (ServerKeyShare)
      • backedUpToClientKeyShareService - Whether this share was backed up to Dynamic’s client share service
    • externalServerKeyShares - (deprecated) Array of external server key shares. Use externalKeySharesWithBackupStatus instead.
    • walletId - Unique wallet identifier

Example

import { authenticatedEvmClient } from './client';
import { ThresholdSignatureScheme } from '@dynamic-labs-wallet/node';

const evmClient = await authenticatedEvmClient();

const wallet = await evmClient.createWalletAccount({
  thresholdSignatureScheme: ThresholdSignatureScheme.TWO_OF_THREE,
  backUpToClientShareService: true,
});

console.log('Wallet created:', wallet.accountAddress);

// Each share includes its backup status
for (const { share, backedUpToClientKeyShareService } of wallet.externalKeySharesWithBackupStatus) {
  console.log('Share backed up to Dynamic:', backedUpToClientKeyShareService);
  if (!backedUpToClientKeyShareService) {
    // Store this share securely — it is not backed up by Dynamic
  }
}

Error Handling

try {
  const wallet = await evmClient.createWalletAccount({
    thresholdSignatureScheme: ThresholdSignatureScheme.TWO_OF_TWO,
    onError: (error) => console.error('Wallet creation error:', error),
  });
  console.log('Wallet created successfully');
} catch (error) {
  console.error('Failed to create wallet:', error);
}