Skip to content

AbstractNexusFactory

aboudjem edited this page Jun 7, 2024 · 1 revision
# AbstractNexusFactory
[Git Source](https://github.com/bcnmy/nexus/tree/main/contracts/factory/AbstractNexusFactory.sol)

**Inherits:**
[Stakeable](/contracts/common/Stakeable.sol/contract.Stakeable.md), [IAbstractNexusFactory](/contracts/interfaces/factory/IAbstractNexusFactory.sol/interface.IAbstractNexusFactory.md)

Provides common functionality for Nexus factories, enabling the creation and management of Modular Smart Accounts.

---

## State Variables
### ACCOUNT_IMPLEMENTATION
Address of the implementation contract used to create new Nexus instances.

*This address is immutable and set upon deployment, ensuring the implementation cannot be changed.*

```solidity
address public immutable ACCOUNT_IMPLEMENTATION;

Important

The ACCOUNT_IMPLEMENTATION address is immutable and set upon deployment to ensure the security and integrity of the Nexus instances.


Functions

constructor

Constructor to set the smart account implementation address and the factory owner.

constructor(address implementation_, address owner_) Stakeable(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.

createAccount

Creates a new Nexus with the provided initialization data.

function createAccount(bytes calldata initData, bytes32 salt) external payable virtual 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.

Caution

Ensure 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 initData, bytes32 salt) external view virtual override returns (address payable expectedAddress);

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
expectedAddress address payable The expected address at which the Nexus contract will be deployed if the provided parameters are used.