Overview
Passkey recovery allows users to regain access to their smart accounts if they lose their primary passkey. This mechanism enables users to register an Externally Owned Account (EOA) as a recovery key. The recovery key can later be used to generate a new passkey and restore access to the smart account—ensuring users maintain full control in a non-custodial setup. For a complete code sample, see the Passkey Recovery Example in the modular wallets web SDK. The recovery process includes two phases:- Registration: The user registers an EOA to act as a recovery key. This key is submitted to the network and added as a signer on the smart account.
Note: Registration must be completed while the user still has access to their original passkey. This ensures that the recovery key is securely authorized.
- Recovery: If the primary passkey is lost, the user can use the recovery key to register a new passkey and resume access.
Prerequisites
Before you implement passkey backup and recovery, make sure you have the following:- An initialized bundler client
- An existing Circle Smart Account already configured with a passkey as the primary signer
- Required dependencies from a supported wallet library and the modular wallets SDK
Steps
To set up passkey backup and recovery, use the following functions from the modular wallets SDK:registerRecoveryAddress: Registers an EOA as a recovery key.executeRecovery: Adds a new WebAuthn credential using the recovery key.estimateRegisterRecoveryAddressGas: Estimates gas for registering a recovery key.estimateExecuteRecoveryGas: Estimates gas for executing the recovery process.
These functions use ERC-4337 user operations to interact with the smart
account.
1. Register a Recovery Address
To allow your users to recover their passkeys, your application should prompt them to associate a recovery address with their smart account while they still have access to their original passkey. The following code sample shows how to register a recovery address and generate a recovery mnemonic. This mnemonic can then be used later to recover their passkey and associated smart account.Note: The user must store the generated mnemonic securely. It serves as
the only credential for recovery if the passkey is lost.
Typescript
2. Initiate the Recovery Process
If a user loses their passkey, they can use the mnemonic from the recovery address to start the recovery flow.Typescript
3. Execute Recovery
After registering the new passkey, callexecuteRecovery to complete the
recovery and restore access to the smart account.
Typescript
WebAuthn credential with the smart account.
4. Use the Recovered Account
After a successful recovery, the user can access the smart account using their new passkey.Typescript
Implementation tips
Use the following tips to improve the reliability and user experience of your passkey recovery implementation.Gas fees
Recovery operations require network gas fees. To improve the user experience, you can either sponsor the gas or estimate and display it to users in advance. Circle recommends using the Gas Station to sponsor gas, as it creates a smoother experience. Recommended approaches:- Sponsor gas fees using Circle Gas Station.
- Estimate gas fees and display them to users:
Typescript
Error handling
The recovery implementation includes built-in validation and error handling for common edge cases:- Detects existing address mappings to support idempotent operations
- Validates that a smart account object is provided for signing
- Handles registration or credential issues gracefully
Tip: Always wrap recovery logic in
try/catch blocks to handle errors
cleanly and provide actionable feedback to users.Best practices
Follow these best practices to increase user trust, security, and recoverability when implementing passkey backup and recovery.1. Educate users
- Clearly explain that losing both the passkey and recovery key results in permanent loss of access.
- Use onboarding tips or modals to reinforce the importance of recovery setup.
- Encourage users to store their recovery mnemonic securely—preferably in a password manager, secure notes app, or hardware vault.
- For a conceptual walkthrough, refer to the User flow examples, which outlines how users might register a recovery key and recover their wallet.
2. Offer redundancy
- Allow users to register multiple recovery keys (EOAs) to improve account resilience.
- Encourage users to store each recovery key in a separate, secure location to avoid single points of failure.
3. Test thoroughly
- Test the recovery flow across supported devices and browsers before deploying to production.
- Simulate common edge cases (e.g., loss of passkey, malformed mnemonic) to verify that fallback logic and error handling behave as expected.
- Consider including recovery flow testing in your CI/CD process if you’re using automated test wallets.
User flow examples
The following user flows describe a possible implementation of the passkey backup and recovery process in your app. The flows are divided into two parts:- Generate your recovery key
- Recover your smart account
Generate your recovery key
After the user signs in with their existing passkey, guide them to set up a recovery key. We recommend offering this option post-onboarding, with access placed under a Settings or Security section in your app. The following steps outline a possible user flow for registering a recovery key:- Select Generate recovery key under Settings or Security section.
- Click Continue to begin generating your recovery key.
- Verify your identity by signing in with your passkey using your touch ID or your device password.
- Click Confirm to register your recovery key on the selected blockchain
network.
Note: The app displays an estimated gas fee for registering the recovery key before submission. - Sign with your passkey to authorize adding the recovery key (EOA) as a signer to your smart account.
- Once registered, securely store the recovery key (mnemonic).
Recover your smart account
After the user has securely stored a recovery key, they can use it to regain access if their original passkey is lost. This flow should be accessible from your app’s sign-in screen or recovery page. The following steps outline a possible user flow for recovering a smart account using a registered recovery key:- Select Recover your wallet from the sign-in screen next to “Lost your passkey?”
- Enter your recovery key, then click Start recovery process.
- After the key is validated, click Continue to create a new passkey.
- Sign with your recovery key to authorize the new passkey.
- Click Confirm to register the new passkey on the blockchain network.
- After successful registration, the app displays a confirmation message.
- The app redirects to your wallet dashboard where you can resume normal operations.