Once you have deployed and initialized your Factory, it is up and running for users to clone the model contract set.
To clone and initialize the model contract, users have to use the deploy function of the Factory passing the model contract initialization data as deployData:
Here you can find some examples of how to create the deployData to pass on.
Model contract implementing LazyInitCapableElement
If the Factory model contract implements LazyInitCapableElement, the deployData is composed as follows:
//host to initialize the lazyInitCapableElement levelvar host ="0x........"//model contract specific parameters to initializevar yourCustomData1 ="test"var yourCustomData2 ="0x..."//encode the parametersvar data = web3.eth.abi.encodeParameters(["string","address"], [yourCustomData1, yourCustomData2]); data = web3.eth.abi.encodeParameters(["address","bytes"], [host, data]);//Initialize the model contract directly when cloning it by the Factoryvar Example = await FactoryContract.methods .deploy(data) .send({from : accounts[1]});
The Factory deploy function automatically calls the lazyInit function of the model contract initialing it.
Model contract implementing DynamicMetadataCapableElement
If the Factory model contract implements DynamicMetadataCapableElement, the deployData is composed as follows:
//host to initialize the lazyInitCapableElement levelvar host ="0x........"//plainUri and dynamicUriResolver to initialize the DynamicMetadataCapableElement levelvar singletonUri ="..."var dynamicUriResolverAddress ="0x..."//model contract specific parameters to initializevar yourCustomData1 ="test"var yourCustomData2 ="0x..."//encode the parametersvar data =web3.eth.abi.encodeParameters(["string","address"], [yourCustomData1, yourCustomData2]);data =web3.eth.abi.encodeParameters(["string","address","bytes"], [singletonUri, dynamicUriResolverAddress, data]);data =web3.eth.abi.encodeParameters(["address","bytes"], [host, data]);//Initialize the model contract directly when cloning it by the Factoryvar Example =awaitFactoryContract.methods.deploy(data).send({from : accounts[1]});
The Factory deploy function automatically calls the lazyInit function of the model contract initialing it.