Documentation Index
Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This guide walks you through creating EVM wallets using Dynamic’s Node SDK. You’ll learn how to set up different threshold signature schemes and understand the security implications of each choice.
Prerequisites
Before you begin, make sure you have:
Step 1: Choose Your Security Model
Dynamic supports two threshold signature schemes, each offering different security and availability trade-offs:
TWO_OF_TWO (Recommended for most use cases)
- Security: Highest - requires both your server and Dynamic’s infrastructure
- Availability: Lower - both parties must be online
- Use case: High-value transactions, maximum security
TWO_OF_THREE
- Security: High - requires 2 out of 3 shares
- Availability: Medium - can tolerate one party being offline
- Use case: Balanced security and availability
Step 2: Create Your First Wallet
Here’s a complete example of creating an EVM wallet:
import { DynamicEvmWalletClient } from '@dynamic-labs-wallet/node-evm';
import { ThresholdSignatureScheme } from '@dynamic-labs-wallet/node';
// Create authenticated client
export const authenticatedEvmClient = async () => {
const client = new DynamicEvmWalletClient({
environmentId: process.env.DYNAMIC_ENVIRONMENT_ID!,
});
await client.authenticateApiToken(process.env.DYNAMIC_AUTH_TOKEN!);
return client;
};
export const createEvmWallet = async ({
thresholdSignatureScheme = ThresholdSignatureScheme.TWO_OF_TWO,
password
}: {
thresholdSignatureScheme?: ThresholdSignatureScheme;
password?: string;
}) => {
const evmClient = await authenticatedEvmClient();
const wallet = await evmClient.createWalletAccount({
thresholdSignatureScheme,
password,
backUpToClientShareService: true,
});
return {
accountAddress: wallet.accountAddress,
publicKeyHex: wallet.publicKeyHex,
walletId: wallet.walletId,
};
};
// Usage example
const wallet = await createEvmWallet({
thresholdSignatureScheme: ThresholdSignatureScheme.TWO_OF_TWO,
password: 'your-secure-password',
});
console.log('Wallet created:', wallet.accountAddress);
Step 3: Handle Errors Gracefully
Always implement proper error handling for wallet creation:
try {
const wallet = await createEvmWallet({
thresholdSignatureScheme: ThresholdSignatureScheme.TWO_OF_TWO,
});
console.log('Wallet created successfully:', wallet.accountAddress);
} catch (error) {
if (error.message.includes('insufficient funds')) {
console.error('Insufficient funds for wallet creation');
} else if (error.message.includes('invalid session')) {
console.error('Invalid session ID - please re-authenticate');
} else {
console.error('Wallet creation failed:', error.message);
}
}
After creating a wallet, you’ll receive important information that should be stored securely:
const wallet = await evmClient.createWalletAccount({
thresholdSignatureScheme: ThresholdSignatureScheme.TWO_OF_TWO
});
// Store these securely in your database
const walletData = {
accountAddress: wallet.accountAddress,
walletId: wallet.walletId,
thresholdScheme: ThresholdSignatureScheme.TWO_OF_TWO,
createdAt: new Date().toISOString(),
};
// Never store externalServerKeyShares in plain text
// They should be encrypted and stored securely
Best Practices
- Password Security: Use strong, unique passwords for each wallet
- Session Management: Implement proper session lifecycle management
- Error Handling: Always handle potential errors during wallet creation
- Monitoring: Log wallet creation events for audit purposes
- Backup Strategy: Implement secure backup strategies for key shares
Next Steps
Now that you’ve created a wallet, you can: