Recommended: JavaScript SDK with React Hooks
For new React apps, we recommend the JavaScript SDK with React Hooks (
@dynamic-labs-sdk/react-hooks) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the React quickstart (JavaScript SDK) to get started.Summary
TheuseWalletPassword hook provides methods to manage wallet password functionality for Dynamic WaaS embedded wallets, allowing users to update passwords, unlock wallets, and check wallet lock states.
To create a wallet with a password, use the createWalletAccount function with the password parameter.
The hook needs to be initialized within a child of DynamicContextProvider.
Functions
updatePassword
Updates the password for an embedded wallet. Can be used to set an initial password or change an existing one.
Parameters:
params: Object containing:accountAddress: string - The wallet addresschainName: ChainEnum - The chain the wallet is associated withnewPassword: string - The new password to setexistingPassword(optional): string - The current password (required when changing an existing password)
Promise<boolean> - true if password update was successful, false otherwise.
Example:
unlockWallet
Unlocks a wallet using the provided password. Once unlocked, the wallet remains unlocked for the rest of the user session.
Parameters:
params: Object containing:accountAddress: string - The wallet addresschainName: ChainEnum - The chain the wallet is associated withpassword: string - The password to unlock the wallet
Promise<boolean> - true if wallet was unlocked successfully, false otherwise.
Example:
checkWalletLockState
Checks the current lock/recovery state of a wallet.
Parameters:
params: Object containing:accountAddress: string - The wallet addresschainName: ChainEnum - The chain the wallet is associated with
Promise<WalletRecoveryState | null> - The wallet’s recovery state, or null if the check failed.
Example:
resetState
Resets the hook’s state back to its initial values, clearing any errors and loading states.
Returns: void
Example:
Properties
state
An object containing the current state of wallet password operations.
Type: WalletPasswordState