Skip to content
Lattice

IAccountFactory

Git Source

Title: IAccountFactory

Author: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80)

Deterministic factory for EIP-2535 Diamond smart accounts. Each account address is a pure function of (factory, owner, salt) and the fixed proxy initcode, so it can be computed off-chain before deployment — enabling counterfactual ERC-4337 initCode onboarding.

The owner is folded into the CREATE2 salt, so a given counterfactual address can only ever be realized with the owner it was derived from (no third party can pre-deploy your address under a different owner). Deployment is idempotent: re-running createAccount for an already-deployed (owner, salt) returns the existing account instead of reverting.

Functions

createAccount

Deploys (or returns the existing) Diamond account for (owner, salt) and initializes it with the factory's fixed facet blueprint and the owner.

function createAccount(address owner, bytes32 salt) external returns (address account);

Parameters

NameTypeDescription
owneraddressThe initial signing owner of the account.
saltbytes32Caller-chosen salt; distinct salts yield distinct accounts for the same owner.

Returns

NameTypeDescription
accountaddressThe deterministic account address (equals getAddress).

getAddress

The counterfactual address createAccount(owner, salt) will deploy to.

function getAddress(address owner, bytes32 salt) external view returns (address account);

Parameters

NameTypeDescription
owneraddressThe prospective owner.
saltbytes32The prospective salt.

Returns

NameTypeDescription
accountaddressThe deterministic CREATE2 address.

accountInit

The initializer contract delegatecalled during each account's diamondCut initialization.

function accountInit() external view returns (address);

Returns

NameTypeDescription
<none>address

Events

AccountCreated

Emitted once when an account is deployed (not re-emitted on idempotent re-calls).

event AccountCreated(address indexed account, address indexed owner, bytes32 salt);

Parameters

NameTypeDescription
accountaddressThe deployed Diamond account.
owneraddressThe account's initial signing owner.
saltbytes32The caller-chosen salt distinguishing accounts for the same owner.

Errors

EmptyBlueprint

Thrown when constructing a factory with an empty facet blueprint (would yield accounts with no callable functions — a permanent, silent misconfiguration since the factory is immutable).

error EmptyBlueprint();