Skip to main content
If the user loses their password, they will lose access to their wallet. There is no way to recover the password or the wallet without it.
Password encryption adds an extra layer of security to embedded wallets by requiring a password to decrypt the user’s key share. This ensures that even if an attacker gains access to the stored key share, they cannot use it without the password.

How it works

When password encryption is enabled:
  1. The user’s key share is encrypted with their password before storage
  2. Operations like signing transactions require the password to decrypt the share
  3. The password is never sent to Dynamic—decryption happens client-side
  4. No single party (Dynamic, encryption provider, or you) can access the wallet alone

Enabling password protection

You can enable password protection in the Dynamic Dashboard:
  1. Navigate to Embedded Wallets.
  2. Toggle Require Password to control whether users must set a password when creating a wallet.
If you enable Require Password, you must provide a password when creating a wallet using the SDK.

Creating a password-protected wallet

Use the createWaasWalletAccounts method with a password parameter:
import { createWaasWalletAccounts } from '@dynamic-labs-sdk/client/waas';

const createSecureWallet = async (password) => {
  await createWaasWalletAccounts({
    chains: ['EVM'],
    password
  });
  
  console.log('Password-protected wallet created');
};

Password management

  • Users set their own password during wallet creation
  • They must enter the password to unlock the wallet
  • Important: If the user forgets their password, wallet recovery may not be possible without a backup

Unlocking a wallet

Before performing operations with a password-protected wallet, you must unlock it using the unlockWallet method.
import { unlockWallet } from '@dynamic-labs-sdk/client/waas';

const handleUnlock = async (walletAccount, password) => {
  await unlockWallet({
    walletAccount,
    password
  });
  
  console.log('Wallet unlocked for this session');
};
Once unlocked, the wallet remains unlocked for the rest of the user session (until logout). The user is only asked for the password once per session. Unlocking one wallet unlocks all wallets associated with the user account. As a result, all wallets for a user must share the same password.

Updating the password

Change an existing password using updateWaasPassword. This will update the password for all wallets associated with the user account.
import { updateWaasPassword } from '@dynamic-labs-sdk/client/waas';

const changePassword = async (walletAccount, currentPassword, newPassword) => {
  await updateWaasPassword({
    walletAccount,
    currentPassword,
    newPassword
  });
  
  console.log('Password updated');
};

Checking wallet lock state

You can check if a wallet is currently locked or ready to use with getWalletRecoveryState. This is more accurate than just checking if a password exists, as it tells you if the wallet is currently unlocked for the session.
import { getWalletRecoveryState } from '@dynamic-labs-sdk/client/waas';

const checkRecoveryState = async (walletAccount) => {
  const { walletReadyState, isPasswordEncrypted } = await getWalletRecoveryState({ walletAccount });
  
  if (walletReadyState === 'encrypted') {
    console.log('Wallet is locked. User needs to enter a password.');
  } else if (walletReadyState === 'ready') {
    console.log('Wallet is unlocked and ready to use.');
  }
};

Complete example

This example demonstrates how to check the wallet state, unlock it if necessary, and then sign a message.
import { signMessage } from '@dynamic-labs-sdk/client';
import { getWalletRecoveryState, unlockWallet } from '@dynamic-labs-sdk/client/waas';

const signWithPassword = async (walletAccount, message, password) => {
  // 1. Check if wallet is locked
  const { walletReadyState } = await getWalletRecoveryState({ walletAccount });
  
  if (walletReadyState === 'encrypted') {
    // 2. Unlock if needed
    if (!password) {
      throw new Error('Password required to unlock wallet');
    }
    
    await unlockWallet({ walletAccount, password });
    console.log('Wallet unlocked');
  }
  
  // 3. Sign message (wallet is now ready)
  const { signature } = await signMessage({ 
    walletAccount, 
    message 
  });
  
  return signature;
};

Security considerations

Password-protected wallets are only as secure as the password itself. Enforce strong password requirements and educate users about password security.
  • Password strength: Require minimum length and complexity
  • No password recovery: If using user-provided passwords, there’s no way to recover a forgotten password without a backup
  • Session-based unlock: Wallets remain unlocked for the session, reducing friction while maintaining security
  • Combine with backups: Consider enabling Google Drive backup for additional recovery options