Extensions
Smart contract extensions utilities and implementations
Extensions add functionality to ERC-7579 accounts.
AccountERC8043Upgradeable: Extension ofAccountERC7579Upgradeablethat implements ERC-8043 init mode, installing modules and using them within a single user operation.
Account
import "@openzeppelin-accounts/contracts/extensions/AccountERC8043Upgradeable.sol";Extension of AccountERC7579Upgradeable that implements atomic module installation and usage
through init mode following ERC-8043.
This extension allows installing and using one or more modules within the same user operation.
Init mode is triggered when userOp.initCode starts with the 4-byte magic value 0x80438043.
The remaining bytes of initCode carry the ABI-encoded module installation payload and an
EIP-712 installation signature from the account owner.
Because the ERC-4337 EntryPoint v0.9 silently ignores initCode for already-deployed accounts,
and because initCode is included in the userOpHash, the module installation parameters are
both inert at the EntryPoint level and cryptographically committed to by the user operation signature.
This pattern is particularly useful for session keys and other modules that need to be installed and immediately used, reducing user operation count from N+1 to 1.
Requires EntryPoint v0.9 or later.
Functions
AccountERC7579Upgradeable
- __AccountERC7579_init()
- __AccountERC7579_init_unchained()
- fallback()
- accountId()
- supportsExecutionMode(encodedMode)
- supportsModule(moduleTypeId)
- installModule(moduleTypeId, module, initData)
- uninstallModule(moduleTypeId, module, deInitData)
- isModuleInstalled(moduleTypeId, module, additionalContext)
- execute(mode, executionCalldata)
- executeFromExecutor(mode, executionCalldata)
- isValidSignature(hash, signature)
- _execute(mode, executionCalldata)
- _installModule(moduleTypeId, module, initData)
- _uninstallModule(moduleTypeId, module, deInitData)
- _fallback()
- _fallbackHandler(selector)
- _checkModule(moduleTypeId, module, additionalContext)
- _extractUserOpValidator(userOp)
- _extractSignatureValidator(signature)
- _decodeFallbackData(data)
- _rawSignatureValidation(, )
EIP712
Account
Events
IERC7579ModuleConfig
Initializable
IERC5267
Errors
AccountERC7579Upgradeable
Account
Initializable
_validateUserOp(struct PackedUserOperation userOp, bytes32 userOpHash, bytes signature) → uint256
internal
#Validates a user operation, checking for the init mode magic value in initCode.
If userOp.initCode starts with INIT_MODE_MAGIC_VALUE, enters init mode:
- Decodes module installation data from
userOp.initCode[4:] - Validates the EIP-712
installationSignatureover the module installation parameters - Installs the modules if validation succeeds
- Continues with normal user operation validation using the forwarded
signatureOtherwise, falls back tosuper._validateUserOp.