Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ERC4337Utils

Library with common ERC-4337 utility functions. See https://eips.ethereum.org/EIPS/eip-4337[ERC-4337].

State Variables

ENTRYPOINT_V07

Address of the entrypoint v0.7.0

IEntryPoint internal constant ENTRYPOINT_V07 = IEntryPoint(0x0000000071727De22E5E9d8BAf0edAc6f37da032);

ENTRYPOINT_V08

Address of the entrypoint v0.8.0

IEntryPoint internal constant ENTRYPOINT_V08 = IEntryPoint(0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108);

SIG_VALIDATION_SUCCESS

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

uint256 internal constant SIG_VALIDATION_SUCCESS = 0;

SIG_VALIDATION_FAILED

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

uint256 internal constant SIG_VALIDATION_FAILED = 1;

Functions

parseValidationData

Parses the validation data into its components. See packValidationData.

function parseValidationData(uint256 validationData)
    internal
    pure
    returns (address aggregator, uint48 validAfter, uint48 validUntil);

packValidationData

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

function packValidationData(address aggregator, uint48 validAfter, uint48 validUntil) internal pure returns (uint256);

packValidationData

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

function packValidationData(bool sigSuccess, uint48 validAfter, uint48 validUntil) internal pure returns (uint256);

combineValidationData

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.

function combineValidationData(uint256 validationData1, uint256 validationData2) internal pure returns (uint256);

getValidationData

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

function getValidationData(uint256 validationData) internal view returns (address aggregator, bool outOfTimeRange);

hash

Get the hash of a user operation for a given entrypoint

function hash(PackedUserOperation calldata self, address entrypoint) internal view returns (bytes32);

factory

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

function factory(PackedUserOperation calldata self) internal pure returns (address);

factoryData

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

function factoryData(PackedUserOperation calldata self) internal pure returns (bytes calldata);

verificationGasLimit

Returns verificationGasLimit from the {PackedUserOperation}.

function verificationGasLimit(PackedUserOperation calldata self) internal pure returns (uint256);

callGasLimit

Returns callGasLimit from the {PackedUserOperation}.

function callGasLimit(PackedUserOperation calldata self) internal pure returns (uint256);

maxPriorityFeePerGas

Returns the first section of gasFees from the {PackedUserOperation}.

function maxPriorityFeePerGas(PackedUserOperation calldata self) internal pure returns (uint256);

maxFeePerGas

Returns the second section of gasFees from the {PackedUserOperation}.

function maxFeePerGas(PackedUserOperation calldata self) internal pure returns (uint256);

gasPrice

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

function gasPrice(PackedUserOperation calldata self) internal view returns (uint256);

paymaster

Returns the first section of paymasterAndData from the {PackedUserOperation}.

function paymaster(PackedUserOperation calldata self) internal pure returns (address);

paymasterVerificationGasLimit

Returns the second section of paymasterAndData from the {PackedUserOperation}.

function paymasterVerificationGasLimit(PackedUserOperation calldata self) internal pure returns (uint256);

paymasterPostOpGasLimit

Returns the third section of paymasterAndData from the {PackedUserOperation}.

function paymasterPostOpGasLimit(PackedUserOperation calldata self) internal pure returns (uint256);

paymasterData

Returns the fourth section of paymasterAndData from the {PackedUserOperation}.

function paymasterData(PackedUserOperation calldata self) internal pure returns (bytes calldata);