CuratedFactory
Inherits: AbstractFactory, AccessControl
Author: cosimo.demedici.eth (https://github.com/ninfa-labs/ninfa-contracts)
Clone factory pattern contract implementing role-based access control in order to deploy clone contracts, i.e. only addresses given the custom _MINTER_ROLE can call the clone function (without any fees being charged), as long as the cloned contract originates from a whitelisted master address.
State Variables
_MINTER_ROLE
_MINTER_ROLE is needed for deploying new instances of the whitelisted collections, it is equivalent to a whitelist of allowed deployers, it can be set by the _CURATOR_ROLE or made payable by derived contracts
bytes32 internal constant _MINTER_ROLE = 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6;_CURATOR_ROLE
_CURATOR_ROLE is needed particularly for the curated factory derived contract, in order for already whitelisted minters (_MINTER_ROLE), to be able to whitelist other minters, e.g. a gallery whitelisting artists, without having to pay in order to whitelist them, by using off-chain signatures and delegating the task to a backend service (using a _CURATOR_ROLE private key). This minimizes security risks by not having to expose the admin private key to the backend service.
bytes32 internal constant _CURATOR_ROLE = 0x850d585eb7f024ccee5e68e55f2c26cc72e1e6ee456acf62135757a5eb9d4a10;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}
Parameters
_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.
Parameters
_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
clone_
address
The address of the new clone.
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
_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
_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