Skip to content

K1ValidatorFactory

aboudjem edited this page Jun 7, 2024 · 1 revision

K1ValidatorFactory

Git Source

Inherits: Stakeable

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

State Variables

ACCOUNT_IMPLEMENTATION

Stores the implementation contract address used to create new Nexus instances.

This address is set once upon deployment and cannot be changed afterwards.

address public immutable ACCOUNT_IMPLEMENTATION;

Important

ACCOUNT_IMPLEMENTATION: This address is immutable and set upon deployment, ensuring the implementation cannot be changed. This ensures the security and integrity of the deployed Nexus accounts.


K1_VALIDATOR

Stores the K1 Validator module address.

This address is set once upon deployment and cannot be changed afterwards.

address public immutable K1_VALIDATOR;

Caution

K1_VALIDATOR: Ensure the address is correct and valid at the time of deployment, as it cannot be changed afterwards.


BOOTSTRAPPER

Stores the Bootstrapper module address.

This address is set once upon deployment and cannot be changed afterwards.

Bootstrap public immutable BOOTSTRAPPER;

Note

BOOTSTRAPPER: This address is critical for the initialization process of new Nexus instances. Verify the address during deployment.


Functions

constructor

Constructor to set the immutable variables.

constructor(address implementation, address factoryOwner, address k1Validator, Bootstrap bootstrapper) Stakeable(factoryOwner);

Parameters

Name Type Description
implementation address The address of the Nexus implementation to be used for all deployments.
factoryOwner address The address of the factory owner.
k1Validator address The address of the K1 Validator module to be used for all deployments.
bootstrapper Bootstrap The address of the Bootstrapper module to be used for all deployments.

Important

constructor: The constructor sets critical immutable state variables that define the behavior and ownership of the factory. Double-check the addresses provided.


createAccount

Creates a new Nexus with a specific validator and initialization data.

function createAccount(address eoaOwner, uint256 index) external payable returns (address payable);

Parameters

Name Type Description
eoaOwner address The address of the EOA owner of the Nexus.
index uint256 The index of the Nexus.

Returns

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

Caution

createAccount: Ensure the EOA owner address and index are correctly specified to avoid misconfiguration. Incorrect parameters can lead to failed deployments or address conflicts.


computeAccountAddress

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

function computeAccountAddress(address, uint256) external view returns (address payable expectedAddress);

Parameters

Name Type Description
<none> address
<none> uint256

Returns

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

Events

AccountCreated

Emitted when a new Smart Account is created, capturing the account details and associated module configurations.

event AccountCreated(address indexed account, address indexed owner, uint256 indexed index);

Errors

ZeroAddressNotAllowed

Error thrown when a zero address is provided for the implementation, K1 validator, or bootstrapper.

error ZeroAddressNotAllowed();