Deploy your Factory through the FoF

Being a Factory deployer, the Factory-of-Factories allows a developer to deploy one or more Factories contracts. Both Factories with and without a business model can be deployed through the Factory-Of-Factories.

As explained before, deploying a Factory through the FoF allows you to:

  • Implement a fee-based business model in your Factory

  • Have your Factory listed in the FoF frontend on the EthereansOS Dapp

Deploy the Factory

The FoF provides the create function:

function create(address[] calldata hosts, string[] calldata uris, bytes[][] calldata factoryBytecodes) external returns (address[][] memory factoryLists, uint256[] memory listPositions);

It allows you to deploy and associate a list of Factories with a host address.

The list of Factories (which can contain one or multiple Factories contracts), is an array of bytes format because the parameter is in fact the bytecodes of the Factories to be deployed.

The create function takes the bytecode and it deploys the Factories contracts.

For each host, with his Factories, you can associate a string containing Metadata useful to associate information to the list of Factories and to rebuild such information on the Frontend. In this way, the FoF aggregates Factories organized by host address in the EthereansOS interface (link coming soon).

The output of the function is:

  • address[][] factoryLists -> the list of addresses of the deployed Factories

  • uint256[] listPositions -> the positions in the storage of the FoF contract of the deployed Factories by the host

Consequently, a host has associated with a storage location, i.e. listPosition, wherein in this location there are all the Factories he created, i.e. factoryList. Each Factory has also its position,i.e. factoryPosition, within the factoryList.

Why can only factories deployed through FoF have a fee-based business model?

Because all the factories deployed through the FoF have as initializer the address of the FoF contract itself.

Factory bytecode

To generate the bytecode to pass to the create function of the FoF in order to deploy your Factory, look at this example:

var Factory = await compile('.../.../.../Factory');
var FactoryBytecode = new web3.eth.Contract(Factory.abi).deploy({data : Factory.bin, arguments : [data]}).encodeABI();

and then pass it to the create function of the FoF:

await FactoryOfFactory.methods.create([accounts[1]], ["Factory test"], [[FactoryBytecode]]).send({from : accounts[1]});

The bytecode can also contain the initialization data of your Factory. In this way, the FoF deploys and initializes your Factory directly.

Look at the following pages for more details.

Last updated