Skip to main content

Overview

This guide shows you how to import existing TON private keys into Dynamic’s MPC wallet system. This is useful when migrating from traditional TON wallets or integrating with existing systems.

Prerequisites

Import Your TON Private Key

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

const tonClient = await authenticatedTonClient();

const wallet = await tonClient.importPrivateKey({
  privateKey: 'YourTonPrivateKey',
  chainName: 'TON',
  thresholdSignatureScheme: ThresholdSignatureScheme.TWO_OF_TWO,
  password: 'your-secure-password',
  backUpToClientShareService: true,
});

console.log('TON wallet imported:', wallet.accountAddress);
console.log('Public key:', wallet.rawPublicKey);
console.log('External server key shares:', wallet.externalServerKeyShares);

Offline Export

If you need to export the private key from existing key shares without a network call, use offlineExportPrivateKey():
const { derivedPrivateKey } = await tonClient.offlineExportPrivateKey({
  keyShares: wallet.externalServerKeyShares,
  derivationPath: undefined, // optional
});

console.log('Exported private key (hex):', derivedPrivateKey);

Security Considerations

  • Private Key Format: Ensure your private key is in the correct format (hex or base64)
  • Password Security: Use a strong, unique password
  • Key Storage: Never store private keys in plain text after import
  • Backup: Ensure you have a secure backup of your original private key
  • Key Share Backup: Use backUpToClientShareService: true for secure key share storage

Threshold Signature Schemes

Choose based on your security and availability needs:
  • TWO_OF_TWO: Maximum security, requires both server and Dynamic
  • TWO_OF_THREE: Balanced security and availability

Next Steps