Account

This document is better viewed at https://docs.openzeppelin.com/contracts/api/account

This directory includes contracts to build accounts for ERC-4337.

Utilities

ERC4337Utils

import "@openzeppelin/contracts/account/utils/draft-ERC4337Utils.sol";

Library with common ERC-4337 utility functions.

See ERC-4337.

parseValidationData(uint256 validationData) → address aggregator, uint48 validAfter, uint48 validUntil internal

Parses the validation data into its components. See packValidationData.

packValidationData(address aggregator, uint48 validAfter, uint48 validUntil) → uint256 internal

Packs the validation data into a single uint256. See parseValidationData.

packValidationData(bool sigSuccess, uint48 validAfter, uint48 validUntil) → uint256 internal

Same as packValidationData, but with a boolean signature success flag.

combineValidationData(uint256 validationData1, uint256 validationData2) → uint256 internal

Combines two validation data into a single one.

The aggregator is set to SIG_VALIDATION_SUCCESS if both are successful, while the validAfter is the maximum and the validUntil is the minimum of both.

getValidationData(uint256 validationData) → address aggregator, bool outOfTimeRange internal

Returns the aggregator of the validationData and whether it is out of time range.

hash(struct PackedUserOperation self, address entrypoint, uint256 chainid) → bytes32 internal

Computes the hash of a user operation for a given entrypoint and chainid.

factory(struct PackedUserOperation self) → address internal

Returns factory from the PackedUserOperation, or address(0) if the initCode is empty or not properly formatted.

factoryData(struct PackedUserOperation self) → bytes internal

Returns factoryData from the PackedUserOperation, or empty bytes if the initCode is empty or not properly formatted.

verificationGasLimit(struct PackedUserOperation self) → uint256 internal

Returns verificationGasLimit from the PackedUserOperation.

callGasLimit(struct PackedUserOperation self) → uint256 internal

Returns callGasLimit from the PackedUserOperation.

maxPriorityFeePerGas(struct PackedUserOperation self) → uint256 internal

Returns the first section of gasFees from the PackedUserOperation.

maxFeePerGas(struct PackedUserOperation self) → uint256 internal

Returns the second section of gasFees from the PackedUserOperation.

gasPrice(struct PackedUserOperation self) → uint256 internal

Returns the total gas price for the PackedUserOperation (ie. maxFeePerGas or maxPriorityFeePerGas + basefee).

paymaster(struct PackedUserOperation self) → address internal

Returns the first section of paymasterAndData from the PackedUserOperation.

paymasterVerificationGasLimit(struct PackedUserOperation self) → uint256 internal

Returns the second section of paymasterAndData from the PackedUserOperation.

paymasterPostOpGasLimit(struct PackedUserOperation self) → uint256 internal

Returns the third section of paymasterAndData from the PackedUserOperation.

paymasterData(struct PackedUserOperation self) → bytes internal

Returns the fourth section of paymasterAndData from the PackedUserOperation.

uint256 SIG_VALIDATION_SUCCESS internal constant

For simulation purposes, validateUserOp (and validatePaymasterUserOp) return this value on success.

uint256 SIG_VALIDATION_FAILED internal constant

For simulation purposes, validateUserOp (and validatePaymasterUserOp) must return this value in case of signature failure, instead of revert.

ERC7579Utils

import "@openzeppelin/contracts/account/utils/draft-ERC7579Utils.sol";

Library with common ERC-7579 utility functions.

See ERC-7579.

execSingle(bytes executionCalldata, ExecType execType) → bytes[] returnData internal

Executes a single call.

execBatch(bytes executionCalldata, ExecType execType) → bytes[] returnData internal

Executes a batch of calls.

execDelegateCall(bytes executionCalldata, ExecType execType) → bytes[] returnData internal

Executes a delegate call.

encodeMode(CallType callType, ExecType execType, ModeSelector selector, ModePayload payload) → Mode mode internal

Encodes the mode with the provided parameters. See decodeMode.

decodeMode(Mode mode) → CallType callType, ExecType execType, ModeSelector selector, ModePayload payload internal

Decodes the mode into its parameters. See encodeMode.

encodeSingle(address target, uint256 value, bytes callData) → bytes executionCalldata internal

Encodes a single call execution. See decodeSingle.

decodeSingle(bytes executionCalldata) → address target, uint256 value, bytes callData internal

Decodes a single call execution. See encodeSingle.

encodeDelegate(address target, bytes callData) → bytes executionCalldata internal

Encodes a delegate call execution. See decodeDelegate.

decodeDelegate(bytes executionCalldata) → address target, bytes callData internal

Decodes a delegate call execution. See encodeDelegate.

encodeBatch(struct Execution[] executionBatch) → bytes executionCalldata internal

Encodes a batch of executions. See decodeBatch.

decodeBatch(bytes executionCalldata) → struct Execution[] executionBatch internal

Decodes a batch of executions. See encodeBatch.

This function runs some checks and will throw a ERC7579DecodingError if the input is not properly formatted.

ERC7579TryExecuteFail(uint256 batchExecutionIndex, bytes returndata) event

Emits when an EXECTYPE_TRY execution fails.

ERC7579UnsupportedCallType(CallType callType) error

The provided CallType is not supported.

ERC7579UnsupportedExecType(ExecType execType) error

The provided ExecType is not supported.

ERC7579MismatchedModuleTypeId(uint256 moduleTypeId, address module) error

The provided module doesn’t match the provided module type.

ERC7579UninstalledModule(uint256 moduleTypeId, address module) error

The module is not installed.

ERC7579AlreadyInstalledModule(uint256 moduleTypeId, address module) error

The module is already installed.

ERC7579UnsupportedModuleType(uint256 moduleTypeId) error

The module type is not supported.

ERC7579DecodingError() error

Input calldata not properly formatted and possibly malicious.

CallType CALLTYPE_SINGLE internal constant

A single call execution.

CallType CALLTYPE_BATCH internal constant

A batch of call executions.

CallType CALLTYPE_DELEGATECALL internal constant

A delegatecall execution.

ExecType EXECTYPE_DEFAULT internal constant

Default execution type that reverts on failure.

ExecType EXECTYPE_TRY internal constant

Execution type that does not revert on failure.