Reference implementation for ERC-6900.
This repository contains the contracts below which are compliant with the latest version of ERC-6900. They are not optimized in both deployments and execution. We’ve explicitly removed some optimizations in favor of clarity.
Important
Unless otherwise stated, these contracts are not audited and SHOULD NOT be used in production.
- Reference account implementations
- ReferenceModularAccount: A simple ERC-6900 compatible account.
- SemiModularAccount: An ERC-6900 account that includes a fallback validation mechanism.
- Factory
- AccountFactory: Deploys both account types.
- ERC-6900 interfaces: src/interfaces
- Helpers
- CollectReturnData
- Constants: ✅ Audited (reports)
- EmptyCalldataSlice: ✅ Audited (reports)
- ValidationResHelpers
- Libraries
- HookConfigLib: ✅ Audited (reports)
- KnownSelectorsLib
- ModuleEntityLib: ✅ Audited (reports)
- ModuleStorageLib
- SparseCalldataSegmentLib: ✅ Audited (reports)
- ValidationConfigLib: ✅ Audited (reports)
- ERC-6900 compatible modules
- Validation modules:
- SingleSignerValidationModule: Enables validation for a single signer (EOA or contract).
- Permission-enforcing hook modules:
- AllowlistModule: Enforces address/selector allowlists.
- ERC20TokenLimitModule: Enforces ERC-20 spend limits.
- NativeTokenLimitModule: Enforces native token spend limits.
- Execution modules:
- TokenReceiverModule: Allows the account to receive ERC-721 and ERC-1155 tokens.
- Validation modules:
- Module utilities
- ModuleEIP712: ✅ Audited (reports)
- ReplaySafeWrapper: ✅ Audited (reports)
Anyone is welcome to submit feedback and/or PRs to improve the code. For standard improvement proposals and discussions, join us at https://github.com/erc6900/resources/issues or Ethereum Magicians.
The default Foundry profile can be used to compile (without IR) and test the entire project. The default profile should be used when generating coverage and debugging.
forge build
forge test -vvv
Since IR compilation generates different bytecode, it's useful to test against the contracts compiled via IR. Since compiling the entire project (including the test suite) takes a long time, special profiles can be used to precompile just the source contracts, and have the tests deploy the relevant contracts using those artifacts.
FOUNDRY_PROFILE=optimized-build forge build
FOUNDRY_PROFILE=optimized-test forge test -vvv
The reference implementation provides a sample factory and deploy script for the factory, account implementation, and the demo validation module SingleSignerValidationModule
. This is not audited nor intended for production use. Limitations set by the GPLv3 license apply.
To run this script, provide appropriate values in a .env
file based on the .env.example
template, then run:
forge script script/Deploy.s.sol <wallet options> -r <rpc_url> --broadcast
Where <wallet_options>
specifies a way to sign the deployment transaction (see here) and <rpc_url>
specifies an RPC for the network you are deploying on.