Fix: Recover Base Smart Wallet After Single-Device Loss
If you lose the single device holding your un-synced passkey, your Base smart wallet is completely locked. To regain access, you must execute a Guardian Key Rotation from a pre-authorized secondary address or input the 12-word fallback recovery phrase directly into the wallet interface to overwrite the active signer set on-chain.
Guardian Execution Script
// Executing Key Rotation via Account Abstraction Paymaster
await smartWallet.execute({
to: contractAddress,
data: encodeFunctionData({
abi: WalletABI,
functionName: 'replaceSigner',
args: [lostPasskeyPubKey, newPasskeyPubKey],
}),
});
Architectural Context: Smart Contract Recovery Conditions and ERC-4337
Unlike traditional Externally Owned Accounts (EOAs), Base smart wallets utilizing ERC-4337 Account Abstraction do not rely on a single immutable private key. The wallet itself is a smart contract that validates signatures from a registered list of owners. This paradigm shift allows for “programmable security,” where the conditions for spending funds are distinct from the conditions for changing the wallet’s owner.
The Role of the EntryPoint and UserOperations
When a recovery is initiated on the Base network, the process does not happen through a standard transaction from the lost device. Instead, it involves a UserOperation submitted to the EntryPoint contract (typically at 0x0000000071727De22E5E9d8BAf0edAc6f37da032).
- Validation Phase: The
EntryPointcalls the smart wallet’svalidateUserOpfunction. - Execution Phase: If the signature (from a Guardian) is valid, the
EntryPointexecutes thereplaceSignercall.
The cryptographic difficulty arises when the primary passkey—the only authorized signer—is lost. In this state, the wallet is “orphaned.” Recovery is only possible if the user previously established a “Guardian” module. This logic is an advanced version of the circle modular wallet sdk two-transport pattern webauthn registration, acting as a multi-signature fail-safe.
Guardian Storage and Slot Management
Guardians are not merely addresses stored in a simple array. In a production-grade Base Smart Wallet, guardian addresses are often hashed and stored in specific storage slots to minimize gas costs during verification. When a recovery request is made, the contract checks the msg.sender or the provided signature against these authorized slots. If you lose your device, the Guardian acts as a bridge, providing the necessary r1 (P-256) or k1 (secp256k1) signature to authorize the rotation of the primary owner’s public key.
Deep Dive: Key Rotation via P-256 and @noble/curves
The Base Smart Wallet predominantly uses WebAuthn passkeys, which leverage the secp256r1 (P-256) curve. If you are a developer assisting a user with recovery, you may need to use @noble/curves to generate a new P-256 keypair on a fresh device before it can be added to the smart contract.
The Problem of ‘Un-synced’ Passkeys
Many users assume passkeys are automatically backed up. However, if “Cloud Sync” (iCloud Keychain or Google Password Manager) was disabled during the initial setup on Base, the private key exists only in the device’s hardware TEE (Trusted Execution Environment). Losing the device means the private key is physically destroyed.
To recover, the new device must generate a new public key. The Guardian then submits this new public key to the smart contract, effectively saying: “I am a trusted guardian, and I authorize this new public key to replace the old, lost one.”
Using viem or ethers, the Guardian must encode the replaceSigner function call precisely. A mismatch in the public key format (e.g., providing uncompressed instead of compressed coordinates) can result in a permanent loss of funds if the contract does not have a “undo” period.
Production-Grade Prevention: Enterprise Guardian Configuration
To ensure a Base Smart Wallet is never permanently lost, users and enterprises must follow a strict “Redundancy-First” onboarding protocol.
1. The 3-2-1 Guardian Strategy
- 3 Signers: Register at least three authorized signers.
- 2 Technologies: Use at least two different signing technologies (e.g., one Apple Passkey, one YubiKey, and one EOA Guardian).
- 1 Cold Storage: Keep one guardian completely offline (a hardware wallet in a safe).
2. Timelock and Social Recovery Policies
Implementing a 48-72 hour timelock on all replaceSigner operations is a critical security policy. This prevents “Social Engineering” attacks where a malicious actor gains control of a guardian’s account.
- Active Monitoring: If a recovery is initiated, the smart wallet should send a notification (via an on-chain event or a linked service).
- Cancellation Power: The primary signer (if still accessible) should have the power to cancel any pending rotation during the timelock period.
3. Environment Schema for Recovery Pipelines
For institutional users, the recovery environment must be standardized to prevent “fat-finger” errors during key rotation.
| Variable | Requirement |
|---|---|
| New Public Key Format | Hex-encoded P-256 $(x, y)$ |
| Guardian Signature Type | ERC-1271 compatible |
| Network ID | 8453 (Base Mainnet) |
| Gas Policy | Paymaster-enabled (to avoid needing ETH on the new account) |
Advanced FAQ: Recovery Technicals
What happens if I don’t have a Guardian but have my 12-word seed?
On the Base Smart Wallet, the 12-word seed acts as a “BIP-39” fallback. However, because the wallet is a smart contract, the seed phrase doesn’t directly derive the contract’s address. Instead, it derives an EOA that is likely pre-registered as a “Master Guardian.” To use it, you must import the seed into a standard wallet (like MetaMask or Coinbase Wallet) and then interact with the Base Smart Wallet’s recovery UI to sign the rotation transaction.
Can I use viem to initiate a recovery without the Coinbase UI?
Yes. If you have the Guardian’s private key, you can use viem to construct a UserOperation. You will need to fetch the current nonce from the EntryPoint, encode the callData for the replaceSigner function, and sign it. This is useful if the official frontend is down or if you are using a custom implementation of the Base Smart Wallet.
Is the ‘Recovery Phrase’ the same as a ‘Passkey’?
No. A passkey is a hardware-bound cryptographic keypair. A recovery phrase is a mnemonic representation of a 128-bit or 256-bit entropy value used to derive keys. In the context of Base, the passkey is for daily use, while the recovery phrase is a “break-glass” mechanism that derives a secondary key with owner-level permissions.
Advanced Manual: On-Chain Rotation Troubleshooting
If the replaceSigner call fails, check the following:
- Nonce Mismatch: Ensure the
UserOperationnonce matches the current nonce of the smart wallet contract on-chain. - Gas Limit: Recovery operations can be gas-intensive due to the signature verification (especially P-256). Ensure your Paymaster has enough balance.
- Owner Overlap: Some contracts prevent adding a signer that is already a guardian. Ensure the new device’s public key is fresh.
- Contract State: Verify that the contract is not currently in a “Frozen” state, which some security modules implement after multiple failed login attempts.
By following this deep-dive guide, users can navigate the complex intersection of WebAuthn and Account Abstraction to ensure their assets on Base remain recoverable, even in the event of total hardware failure.