Skip to content
Lattice

ERC4337Validation

Git Source

Inherits: IAccount, IERC4337Validation

Title: ERC4337Validation

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from eth-infinitism account-abstraction (https://github.com/eth-infinitism/account-abstraction)

ERC-4337 validation facet — makes the Diamond a smart account drivable by a configured EntryPoint. validateUserOp gates on the EntryPoint, validates the user op signature against the AccountSigner owner, and pays the EntryPoint its prefund.

Stateless delegator — logic/storage live in ERC4337ValidationLib. The EntryPoint is configurable (v0.7/v0.8/v0.9) rather than hardcoded.

Notes:

  • lattice-version: 0.1.0
  • lattice-source: ERC-4337

Functions

validateUserOp

Validates a user operation on behalf of the EntryPoint.

MUST be gated to msg.sender == entryPoint. MUST NOT revert on a signature mismatch — instead return validationData with the low bit set (SIG_VALIDATION_FAILED == 1). If missingAccountFunds is non-zero, the account MUST transfer at least that much to the EntryPoint (msg.sender).

function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds)
        external
        virtual
        returns (uint256 validationData);

Parameters

NameTypeDescription
userOpPackedUserOperationThe packed user operation.
userOpHashbytes32The EntryPoint-computed hash the signature is over (already domain-bound).
missingAccountFundsuint256The prefund the account owes the EntryPoint for this op.

Returns

NameTypeDescription
validationDatauint256Packed authorizer(160) || validUntil(48) || validAfter(48); 0 = valid,
1 = signature failure.

entryPoint

The ERC-4337 EntryPoint trusted to call validateUserOp.

function entryPoint() external view virtual returns (address);

Returns

NameTypeDescription
<none>address

setEntryPoint

Sets the trusted EntryPoint. Admin only.

function setEntryPoint(address entryPoint_) external virtual;

Parameters

NameTypeDescription
entryPoint_address

exportSelectors

ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).

Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches forge inspect ERC4337Validation methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: entryPoint() 0xb0d691fe setEntryPoint(address) 0x584465f2 validateUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32,uint256) 0x19822f7c

function exportSelectors() external pure virtual returns (bytes memory selectors);

Returns

NameTypeDescription
selectorsbytes