Extensions

Smart contract extensions utilities and implementations

Extensions add functionality to ERC-7579 accounts.

  • AccountERC8043Upgradeable: Extension of AccountERC7579Upgradeable that implements ERC-8043 init mode, installing modules and using them within a single user operation.

Account

AccountERC8043Upgradeable

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.

_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:

  1. Decodes module installation data from userOp.initCode[4:]
  2. Validates the EIP-712 installationSignature over the module installation parameters
  3. Installs the modules if validation succeeds
  4. Continues with normal user operation validation using the forwarded signature Otherwise, falls back to super._validateUserOp.