API Reference

Smart contract API reference

This package provides a production-ready ERC-4337 and ERC-7579 smart account and a set of ERC-7579 modules that can be installed on any ERC-7579 compliant account.

Modules, extensions and utilities are documented in their own pages:

  • Modules: Validators, executors and the signer, multisig and session key primitives they are built from.
  • Extensions: Account extensions such as ERC-8043 init mode.
  • Utilities: Libraries and helpers for multisignatures, crosschain signatures and FHE coordination.

Account

OpenAccount

OpenAccountImplementation

Factory

OpenAccountFactory

import "@openzeppelin-accounts/contracts/OpenAccount.sol";

A modular smart account implementation.

Functions

ERC1155Holder
ERC721Holder
AccountERC7579Upgradeable
EIP712
Account
Initializable

initialize(uint256[] moduleTypeIds, address[] modules, bytes[] initDatas, Mode configMode, bytes configCalldata)

public

#

Initializes the account with a validator or executor module.

It receives an array of moduleTypeIds, modules, and initDatas that are used to install modules during initialization. It also receives a mode and executionCalldata that are used to execute the account, these can be used to configure the account.

Set the configCalldata to bytes("") to skip the configuration call.

_validateUserOp(struct PackedUserOperation userOp, bytes32 userOpHash, bytes signature) → uint256

internal

#

Validates a user operation with _signableUserOpHash and returns the validation data if the module specified by the first 20 bytes of the nonce key is installed. Falls back to Account-_validateUserOp otherwise.

See _extractUserOpValidator for the module extraction logic.

OpenAccountModuleTypeIdsLengthMismatch()

error

#

Thrown when the length of the module type ids, modules, and init datas do not match during initialization.

OpenAccountNoValidatorOrExecutor()

error

#

Thrown when the account is initialized without a validator or executor module.

import "@openzeppelin-accounts/contracts/OpenAccountFactory.sol";

Implementation contract for the OpenAccount factory.

Functions

UUPSUpgradeable
OpenAccount
ERC1155Holder
ERC721Holder
AccountERC7579Upgradeable
EIP712
Account
Initializable

constructor()

public

#

_validateUserOp(struct PackedUserOperation userOp, bytes32 userOpHash, bytes signature) → uint256

internal

#

_authorizeUpgrade(address newImplementation)

internal

#

Function that should revert when msg.sender is not authorized to upgrade the contract. Called by upgradeToAndCall.

Normally, this function will use an access control modifier such as Ownable-onlyOwner.

function _authorizeUpgrade(address) internal onlyOwner {}
import "@openzeppelin-accounts/contracts/OpenAccountFactory.sol";

A factory contract to create OpenAccount instances on demand.

Each account is created as a minimal ERC-1967 proxy clone that delegates to the implementation contract. The proxy follows the ERC-1967 standard for proxy storage slots, storing the implementation address at bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1).

See https://eips.ethereum.org/EIPS/eip-1967 for the full specification.

implementation() → address

public

#

Returns the OpenAccount implementation contract address.

This is the logic contract that all created proxy clones will delegate to.

predictAddress(uint256[] moduleTypeIds, address[] modules, bytes[] initDatas, Mode configMode, bytes configCalldata, bytes32 salt) → address

public

#

Predicts the address of an OpenAccount before it is created.

The address is deterministically computed based on the initialization parameters and salt. Each account is deployed as an ERC-1967 proxy clone.

createAndInitialize(uint256[] moduleTypeIds, address[] modules, bytes[] initDatas, Mode configMode, bytes configCalldata, bytes32 salt) → address

public

#

Creates and initializes a new OpenAccount instance.

Deploys a minimal ERC-1967 proxy clone using CREATE2 for deterministic addresses. The proxy delegates all calls to the implementation contract and maintains its own storage. If an account at the predicted address already exists, returns that address without redeploying.