Skip to content

BiconomyMetaFactory

aboudjem edited this page Jun 7, 2024 · 1 revision

BiconomyMetaFactory

Git Source

Inherits: Stakeable

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

Utilizes the Stakeable for staking requirements. This contract serves as a 'Meta' factory to generate new Nexus instances using specific chosen and approved factories.

Can whitelist factories, deploy accounts with chosen factory and required data for that factory. The factories could possibly enshrine specific modules to avoid arbitrary execution and prevent griefing.


State Variables

factoryWhitelist

Stores the factory addresses that are whitelisted.

mapping(address => bool) public factoryWhitelist;

Functions

constructor

Constructor to set the owner of the contract.

constructor(address owner_) Stakeable(owner_);

Parameters

Name Type Description
owner_ address The address of the owner.

addFactoryToWhitelist

Adds an address to the factory whitelist.

function addFactoryToWhitelist(address factory) external onlyOwner;

Parameters

Name Type Description
factory address The address to be whitelisted.

removeFactoryFromWhitelist

Removes an address from the factory whitelist.

function removeFactoryFromWhitelist(address factory) external onlyOwner;

Parameters

Name Type Description
factory address The address to be removed from the whitelist.

deployWithFactory

Deploys a new Nexus with a specific factory and initialization data.

Uses factory.call(factoryData) to post the encoded data for the method to be called on the Factory. These factories could enshrine specific modules to avoid arbitrary execution and prevent griefing. Another benefit of this pattern is that the factory can be upgraded without changing this contract.

function deployWithFactory(address factory, bytes calldata factoryData) external payable returns (address payable createdAccount);

Parameters

Name Type Description
factory address The address of the factory to be used for deployment.
factoryData bytes The encoded data for the method to be called on the Factory.

Returns

Name Type Description
createdAccount address payable The address of the newly created Nexus account.

Important

Ensure the factory address is whitelisted before attempting deployment. Unauthorized factories can lead to security vulnerabilities.


isFactoryWhitelisted

Checks if an address is whitelisted.

function isFactoryWhitelisted(address factory) public view returns (bool);

Parameters

Name Type Description
factory address The address to check.

Returns

Name Type Description
<none> bool True if the factory is whitelisted, false otherwise.

Errors

FactoryNotWhitelisted

Error thrown when the factory is not whitelisted.

error FactoryNotWhitelisted();

InvalidFactoryAddress

Error thrown when the factory address is zero.

error InvalidFactoryAddress();

ZeroAddressNotAllowed

Error thrown when the owner address is zero.

error ZeroAddressNotAllowed();

CallToDeployWithFactoryFailed

Error thrown when the call to deploy with factory failed.

error CallToDeployWithFactoryFailed();