Factory without a business model
In order to code your Factory without a fee-based business model, you can:
Take the standard
Factory
contract provided by the swissKnife Library and deploy it
or:
Implement the standard
Factory
contract in your custom Factory contract to build your custom logic
Even your Factory without a business model can be deployed through the Factory-Of-Factories in order to be listed in the Factory-Of-Factories frontend (link coming soon).
In the following paragraph, you can find an example on how to implement the standard Factory
contract in your custom Factory.
How to Code a custom Factory without a business model
Your custom Factory contract must integrate the standard Factory
contract as follows:
And at the interface level, if any, as follows:
Through this integration, your contract acquires all LazyInitCapableElement
capabilities.
You also need to insert the constructor
into your smart contract. This allows you to deploy and initialize it in the “traditional” way as well as through another factory.
Coded like this, the constructor
calls the standard Factory
constructor
and thus can use all logic of the Factory
, such as that which allows it to execute lazyInitData
.
After integrating the constructor
, you need to override _factoryLazyInit
virtual function, which manages data initialization of your model contract.
In the example below, _factoryLazyInit
initializes three parameters: customFactoryParameter1
, customFactoryParameter2
and customFactoryParameter3
.
Of course, if your custom Factory doesn’t have any additional data to initialize, the _factoryLazyInit
override function doesn’t have to be included.
Now you have a custom Factory contract which can clone and initialize a model contract.
Last updated