Skip to main content

Function Signature

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

Description

Creates a new SVM 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 for handling creation errors
  • 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
    • rawPublicKey - Raw public key
    • 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 { authenticatedSvmClient } from './client';
import { ThresholdSignatureScheme } from '@dynamic-labs-wallet/node';

const svmClient = await authenticatedSvmClient();

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

console.log('Solana 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 svmClient.createWalletAccount({
    thresholdSignatureScheme: ThresholdSignatureScheme.TWO_OF_TWO,
    onError: (error: Error) => {
      console.error('Wallet creation error:', error);
    },
    backUpToClientShareService: true,
  });
  console.log('Wallet created successfully');
} catch (error) {
  console.error('Failed to create wallet:', error);
}