Skip to content

NexusAccountFactory

aboudjem edited this page Jun 7, 2024 · 1 revision

NexusAccountFactory

Git Source

Inherits: AbstractNexusFactory

Manages the creation of Modular Smart Accounts compliant with ERC-7579 and ERC-4337 using a factory pattern.

Functions

constructor

Constructor to set the smart account implementation address and owner.

constructor(address implementation_, address owner_) AbstractNexusFactory(implementation_, owner_);

Parameters

Name Type Description
implementation_ address The address of the Nexus implementation to be used for all deployments.
owner_ address The address of the owner of the factory.

Important

constructor: The constructor sets critical state variables that define the behavior and ownership of the factory. Ensure that the addresses provided are accurate.


createAccount

Creates a new Nexus account with the provided initialization data.

function createAccount(bytes calldata initData, bytes32 salt) external payable override returns (address payable);

Parameters

Name Type Description
initData bytes Initialization data to be called on the new Smart Account.
salt bytes32 Unique salt for the Smart Account creation.

Returns

Name Type Description
<none> address payable The address of the newly created Nexus account.

Caution

createAccount: Ensure that the initData and salt are correctly specified to avoid deploying multiple accounts at the same address or creating unintended behavior.


computeAccountAddress

Computes the expected address of a Nexus contract using the factory's deterministic deployment algorithm.

function computeAccountAddress(bytes calldata, bytes32) external view override returns (address payable expectedAddress);

Parameters

Name Type Description
<none> bytes N/A (read from the calldata directly from the assembly code).
<none> bytes32 N/A (read from the calldata directly from the assembly code).

Returns

Name Type Description
expectedAddress address payable The expected address at which the Nexus contract will be deployed if the provided parameters are used.

Note

computeAccountAddress: The function reads from the calldata directly using assembly code, ensuring deterministic address computation.