Safe and ERC-7579
The Safe7579 Adapter is a smart contract developed by Rhinestone and Safe to make Safe Smart Accounts compliant with ERC-7579. Through this, 14 audited modules (opens in a new tab) developed by Rhinestone will be available for builders building with the Safe7579 Adapter, such as a dead man switch, flash-loan, social recovery, etc.
Additionally, the Rhinestone registry provides per-transaction security checks on modules, so modules with security compromises are automatically disabled for your account.
Safe7579 Adapter
As ERC-7579 is a superset of ERC-4337, the Safe7579 Adapter ensures full compliance with ERC-4337. The Safe7579 Adapter is both a Safe Module and a Fallback Handler.
- Safe Module: It extends the functionality of a Safe account, allowing it to utilize ERC-7579 modules.
- Fallback Handler: It is a fallback handler because certain functions, such as validateUserOp in ERC-7579, are not natively supported by Safe.
Additionally, a launchpad contract facilitates the setup of new Safes with Safe7579 Adapter.
Creation of new Safes compatible with ERC-7579
The launchpad contract works around the 4337 limitations, which allows the deployment of exactly one contract whose address matches the sender of the user operation.
The creation of new Safes occurs in the following three high-level steps.
Creation by Factory
- Bundler informs
Entrypoint
tohandleUserOps
. - Entrypoint calls
SenderCreator
to callSafeProxyFactory
. SenderCreator
requestssafeProxy
creation fromSafeProxyFactory
usingcreateProxyWithNonce
.SafeProxyFactory
creates a newSafeProxy
usingcreate2
.SafeProxy
is created with a singleton address set toLaunchpad
.initHash
is stored in theSafeProxy
storage.
Validation Phase
Entrypoint
validates user operations inSafeProxy
viavalidateUserOp
.SafeProxy
delegates validation toLaunchpad
.Launchpad
ensures the presence ofinitHash
from phase one and callsSafe7579.launchpadValidators
.ValidatorModule
gets installed byLaunchpad
.ValidatorModule
validates user operations and returnspackedValidationData
.Launchpad
returns packedValidationData toSafeProxy
,SafeProxy
returns toEntrypoint
.
Execution Phase
Entrypoint
triggerslaunchpad.setupSafe()
inSafeProxy
.SafeProxy
delegates the setup toLaunchpad
.LaunchPad
upgradesSafeStorage.singleton
toSafeSingleton
.LaunchPad
callsSafeProxy.setup()
to initializeSafeSingleton
.- Setup function in
SafeProxy.setup()
delegatecalls tolauchpad.initSafe7579
. initSafe7579()
initializesSafe7579
with executors, fallbacks, hooks,IERC7484
registry.
The following detailed sequence outlines the creation, validation, and execution phases in the system's operation.