An implementation of account abstraction mechanisms using Solidity, featuring SimpleAccount
contracts and integration with zkSync. This project demonstrates how to build, deploy, and test account abstraction contracts using Foundry, enabling more flexible account behaviors and customization of transaction validation logic.
Account abstraction allows for customizable account logic on the Ethereum blockchain. By abstracting the account model, developers can implement advanced functionalities like custom signature validation, meta-transactions, and enhanced security features. This project implements account abstraction concepts through the SimpleAccount
contract and extends support for zkSync, providing a foundation for more advanced account behaviors and scalability solutions.
- SimpleAccount Contract: A basic implementation of an account that supports custom validation logic.
- zkSync Integration: Extended support for zkSync network with specific contracts and tests.
- Deployment Scripts: Automated deployment using Foundry scripts.
- Comprehensive Testing: A full suite of tests written in Solidity using Forge test framework.
- Modular Configuration: Easy-to-manage network configurations via
HelperConfig
.
├── src/
│ ├── SimpleAccount.sol # Main EVM account contract.
│ ├── Errors.sol # Custom error definitions.
│ └── zksync/
│ ├── SimpleAccountZkSync.sol # zkSync-specific account contract.
│ └── Errors.sol # Custom error definitions.
├── script/
│ ├── DeploySimpleAccount.s.sol # Script to deploy SimpleAccount.
│ ├── HelperConfig.s.sol # Network configuration script.
│ └── NetworkConfig.sol # Network configuration data structure.
├── test/
│ ├── SimpleAccountTest.t.sol # Test suite for SimpleAccount.
│ └── zksync/
│ └── SimpleAccountZkSyncTest.t.sol # Tests for zkSync integration.
├── lib/ # External libraries and submodules.
│ ├── account-abstraction/ # Account abstraction standards.
│ ├── forge-std/ # Standard library for Forge.
│ ├── foundry-era-contracts/ # ERA contracts for Foundry.
│ └── openzeppelin-contracts/ # Standard security libraries.
├── foundry.toml # Foundry configuration file.
├── remappings.txt # Dependency remappings.
├── README.md # Project documentation.
└── ... # Other configuration and helper files.
- Foundry: Install Foundry by following the Foundry installation guide.
- Git Submodules: The project uses submodules for external libraries.
-
Clone the Repository:
git clone https://github.com/sumit03guha/account-abstraction cd account-abstraction
-
Initialize Submodules:
git submodule update --init --recursive
-
Install Dependencies:
forge install
-
Build the Contracts:
forge build
Use the provided deployment scripts to deploy the SimpleAccount
contract.
forge script script/DeploySimpleAccount.s.sol --broadcast
Note: You may need to provide additional flags such as
--rpc-url
and--private-key
for network and account configurations.
Execute the test suite to ensure contracts function as expected.
forge test --match-contract SimpleAccountTest
To run tests specifically for zkSync integration:
forge test --match-contract SimpleAccountZkSyncTest --zksync --zk-enable-eravm-extensions=true
The HelperConfig
script sets up network configurations based on the chain ID.
- Supported Networks:
- Anvil or Anvil-zksync (Local blockchain)
- Sepolia
- zkSync
Ensure code adheres to the style guidelines.
forge fmt
This project includes support for zkSync, a Layer 2 scalability solution. The zkSync-specific contracts and tests are located in the src/zksync/
and test/zksync/
directories.
-
Contracts:
SimpleAccountZkSync.sol
: Account contract adapted for zkSync.Errors.sol
: Error definitions specific to zkSync.
-
Tests:
SimpleAccountZkSyncTest.t.sol
: Test suite for the zkSync account contract.
forge test --match-contract SimpleAccountZkSyncTest --zksync --zk-enable-eravm-extensions=true
Note: You may need to configure your Foundry settings to interact with zkSync's testnet or mainnet. Ensure that the appropriate RPC endpoints and chain IDs are set.
- Foundry: Smart contract development toolchain.
- OpenZeppelin Contracts: Standard library for secure smart contract development.
- Account Abstraction Library: Implements account abstraction functionalities.
- Forge Std Library: Standard library for testing.
- foundry-era-contracts: ERA contracts integration for Foundry.
The foundry.toml
file contains project configurations. Key settings include:
- Compiler Version: Solidity
0.8.28
. - EVM Version:
cancun
. - Optimizer: Enabled with
200
runs. - Via-IR: Enabled for Yul intermediate representation.
Contributions are welcome! Please open issues and submit pull requests for any improvements.
-
Fork the Repository.
-
Create a New Branch:
git checkout -b feature/your-feature-name
-
Commit Your Changes:
git commit -am 'Add some feature'
-
Push to the Branch:
git push origin feature/your-feature-name
-
Open a Pull Request.
- Ethereum Foundation: For the account abstraction EIPs and research.
- zkSync Team: For providing Layer 2 scalability solutions.
- Foundry Team: For providing a robust development environment.
- OpenZeppelin: For secure and reliable smart contract libraries.