Clone the model contract
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:
1
function deploy(bytes calldata deployData) external payable returns(address deployedAddress, bytes memory deployedLazyInitResponse);
Copied!
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:
1
//host to initialize the lazyInitCapableElement level
2
var host = "0x........"
3
//model contract specific parameters to initialize
4
var yourCustomData1 = "test"
5
var yourCustomData2 = "0x..."
6
//encode the parameters
7
var data = web3.eth.abi.encodeParameters(["string", "address"], [yourCustomData1, yourCustomData2]);
8
data = web3.eth.abi.encodeParameters(["address", "bytes"], [host, data]);
9
10
//Initialize the model contract directly when cloning it by the Factory
11
var Example = await FactoryContract.methods
12
.deploy(data)
13
.send({from : accounts[1]});
Copied!
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:
1
//host to initialize the lazyInitCapableElement level
2
var host = "0x........"
3
//plainUri and dynamicUriResolver to initialize the DynamicMetadataCapableElement level
4
var singletonUri = "..."
5
var dynamicUriResolverAddress = "0x..."
6
//model contract specific parameters to initialize
7
var yourCustomData1 = "test"
8
var yourCustomData2 = "0x..."
9
//encode the parameters
10
var data = web3.eth.abi.encodeParameters(["string", "address"], [yourCustomData1, yourCustomData2]);
11
data = web3.eth.abi.encodeParameters(["string", "address", "bytes"], [singletonUri, dynamicUriResolverAddress, data]);
12
data = web3.eth.abi.encodeParameters(["address", "bytes"], [host, data]);
13
14
//Initialize the model contract directly when cloning it by the Factory
15
var Example = await FactoryContract.methods
16
.deploy(data)
17
.send({from : accounts[1]});
Copied!
The Factory deploy function automatically calls the lazyInit function of the model contract initialing it.