Advanced
Wallet Recovery
๐ Recovery Feature
๐ Overview
The recovery feature allows users to enable a wallet recovery mechanism for their Safe wallet in case of access loss. This feature includes:
- Recovery activation: Configuration of a recovery address with a delay and collection of personal data
- Recovery execution: Ownership transfer after delay expiration (administrative operation)
- Recovery cancellation: Ability to cancel a recovery in progress
๐๏ธ Architecture
Smart Contract: RecoveryModule
The RecoveryModule contract manages all recovery logic:
๐ฆ Deployed Contracts
Original Contract (Deprecated)
- Address:
0xa7480cc788b42dEF5F7dd979Bf9ce539CFB93DD9 - Network: Arbitrum Sepolia
- Status: Deprecated - do not use
- Issue: Function signature with
onlySafe(safe)that caused execution errors
Current Contract (Production)
- Address:
0x13Ba85EC17A55BE3354bC540814D97e420b9f8C8 - Network: Arbitrum Sepolia
- Status: Active - used in production
- Verified: โ Verified on Arbiscan
- Improvement: Simplified signature using
msg.senderinstead of parameter
Differences Between Contracts
| Aspect | Original Contract | Current Contract |
|---|---|---|
| enableRecovery signature | enableRecovery(safe, recoveryAddress, delay, description) | enableRecovery(recoveryAddress, delay, description) |
| cancelRecovery signature | cancelRecovery(safe) | cancelRecovery() |
| disableRecovery signature | disableRecovery(safe) | disableRecovery() |
| Modifier | onlySafe(safe) | Uses msg.sender directly |
| Compatibility | โ Execution issues | โ Works correctly |
Why Two Contracts?
- Initial problem: The first contract had a function signature that caused "Execution failed" errors when called from the Safe
- Solution: Simplified signature by using
msg.senderinstead of passing the Safe address as a parameter - Migration: Deployment of a new contract with the corrected signature
๐ง Verification Scripts
Status Check Script
Features:
- Recovery configuration verification
- Display of delay and recovery address
- Verification if recovery can be executed
- Automatic connection to Arbitrum Sepolia
Example output:
Deployment Script
Arbiscan Verification Script
๐ Arbiscan Verification
Verified Contract
- URL: https://sepolia.arbiscan.io/address/0x13Ba85EC17A55BE3354bC540814D97e420b9f8C8#code
- Interface: Complete with "Read Contract" and "Write Contract"
Available Read Functions
getRecoveryConfig(address safe): Retrieve recovery configurationcanExecuteRecovery(address safe): Check if recovery can be executedrecoveryConfigs(address safe): Mapping of configurationspendingRecoveries(address safe): Mapping of pending recoveries
Available Write Functions
enableRecovery(address recoveryAddress, uint256 delay, string description): Enable recoverydisableRecovery(): Disable recoveryinitiateRecovery(address safe): Initiate the recovery processcancelRecovery(): Cancel a recovery in progressexecuteRecovery(address safe, address[] newOwners, uint256 threshold): Execute recovery
API Endpoints
1. Recovery Activation
Response:
2. Recovery Cancellation
3. Recovery Execution (Administrative)
โ ๏ธ Internal administrative endpoint - Only the Ibex team can use this endpoint.
๐ Workflow
1. Recovery Activation
- User configures their personal data via the
ENABLE_RECOVERYoperation - API uses environment variables for recovery address and delay
- Message is signed with passkey
- Transaction is executed on the smart contract with the new signature
- Recovery is activated with the default delay (86400 seconds = 1 day)
- Personal data is saved to the database
2. Recovery Cancellation
- Current owners can cancel via the
CANCEL_RECOVERYoperation - Message is signed with passkey
- Transaction is executed on the smart contract
- Recovery process is stopped
- Safe remains under control of current owners
3. Recovery Execution (Administrative)
- After delay expiration, the Ibex team can execute recovery
- New owners are defined
- Safe is transferred to new owners
- Operation is recorded in the database
๐ก๏ธ Security
Delay Constraints
- Minimum: 1 day (86400 seconds)
- Maximum: 30 days (2592000 seconds)
- Default: 1 day (configured via
RECOVERY_DEFAULT_DELAY)
Permissions
- Activation: Only Safe owners
- Execution: Only Ibex team (administrative endpoint)
- Cancellation: Only current owners
Verifications
- Ethereum address validation
- Delay verification
- Permission checks
- Mandatory passkey signature
- Personal data validation
- API_KEY authentication for administrative execution
๐ Database
Added Operation Types
Data Structure
Each recovery operation is recorded in the Operation table with:
- Type: Recovery operation type
- Parameters: Personal data (firstName, lastName, birthDate, etc.)
- Encoded data: Blockchain transaction
๐ Deployment
1. Deploy Smart Contract
2. Verify Contract on Arbiscan
3. Update Contract Address
4. Deploy API
๐งช Testing
Unit Tests
Integration Tests
Manual Verification
๐ Usage
Complete Example
๐ง Configuration
Environment Variables
Permissions
๐ฏ Future Features
- Multi-level recovery: Multiple recovery addresses
- Notifications: Alerts on activation/initiation
- Social recovery: Recovery via trusted contacts
- Advanced timelock: Progressive delays
- Conditional recovery: Based on specific events
- User interface: Dashboard to manage recoveries
- History: Complete traceability of recovery operations