PayableFactory

Git Source

Inherits: AbstractFactory, Owned

Author: cosimo.demedici.eth (https://github.com/ninfa-labs/ninfa-contracts)

Clone factory pattern contract without any access control but requiring a flat fee payment in order to deploy clones, as long as they are cloned from a whitelisted master address.

State Variables

cloningFee

The flat fee for creating a new clone.

uint256 public cloningFee;

Functions

constructor

The constructor sets role-based access control granting the factory deployer account both DEFAULT_ADMIN_ROLE and the custom _CURATOR_ROLE.

Fee information is set in the base {AbstractFactory-constructor

constructor(uint256 _feeNumerator, address _feeRecipient) AbstractFactory(_feeNumerator, _feeRecipient);

Parameters

Name
Type
Description

_feeNumerator

uint256

The numerator of the fee fraction.

_feeRecipient

address

The address to receive the fee.

clone

Clone function to create a new instance of a contract. This function is payable and requires a fee.

Parameters

Name
Type
Description

_instance

address

The address of the instance to clone.

_salt

bytes32

A random number of our choice. Generated with https://web3js.readthedocs.io/en/v1.2.11/web3-utils.html#randomhex _salt could also be dynamically calculated in order to avoid duplicate clones and for a way of finding predictable clones if salt the parameters are known.

_data

bytes

The initialization data for the clone.

Returns

Name
Type
Description

clone_

address

The address of the new clone.

setFactoryFee

Sets the factory fee.

Parameters

Name
Type
Description

_newCloningFee

uint256

The updated factory fee.

setMaster

Whitelist or unwhitelist a master implementation.

External visibility because it is meant to be needed by all derived contracts, i.e. no point in having a public getter for it, to avoid extra code.

Parameters

Name
Type
Description

_instance

address

Address of the master implementation to whitelist.

_isWhitelisted

bool

Bool to set the implementation as whitelisted or not.

setSalesFeeInfo

see AbstractFactory-salesFeeInfo

Parameters

Name
Type
Description

_feeRecipient

address

The address to receive the fee.

_feeNumerator

uint256

The numerator of the fee fraction.

withdraw

A function to withdraw the balance of the contract deriving from either sales fees accessed via AbstractFactory-salesFeeInfo, or as flat fees for cloning defined in derived contracts, i.e. {PayableFactory-clone}.

Last updated