This repository provides a modular ERC4337-compatible smart contract wallet. It is designed to enable easy integration of new features while maintaining simplicity and security. Each module is separate smart contract with his own storage. Ideally for production ready code this pattern should become Diamond Proxy but for simplicity in this solution I am using simple namespaces storage based on OZ practices. With Diamond more robust architecture will be achieved because user could easily add different facets based on his need. Please have in mind that this implementation is not production/audit ready code but serves as a proof of concept and it developed in less than 2 days.
ERC4337 introduces Account Abstraction, enabling smart contract wallets to compete with traditional Externally Owned Accounts (EOAs). This wallet builds upon this standard to provide:
- Flexibility: Modular architecture for feature expansion.
- Usability: Simplified integration and operation.
- Security: Namespaced storage for isolated and secure module data.
Instead of the Diamond proxy standard, this wallet uses namespaced storage for managing module states. This choice was made to:
- Simplify contract design and deployment.
- Avoid common pitfalls in complex proxy setups.
- Simple and secure upgrade of the modules
The wallet integrates with a Verifier Contract deployed on the Ethereum mainnet for passkey management using Webauthn service. This service is utilized within the Ownership Management Module to validate signatures. Entire passkey management lays in ownership module and relies on on chain verification.
- Transfer and recover ownership securely.
- Includes passkey management.
- Schedule and automate periodic investments.
- Customize intervals and amounts for seamless execution.
Inside this module user can make order. When creating order user can choose what asset he wants to buy, what asset he wants to spend, how much and how often. Smart contract simply checks if enough time passed since last trade execution and checks for slippage. Execution function is public for anyone. Anyone can call it but smart DCA Module integrates oracle and check that spot price is not smaller than oracle for more than 0.5%. This is done for simplicity purpose. Alternatively, restriction module could be implemented.
To build and test the smart contract wallet, use the following commands:
forge build
forge test