I have been trying to develop a parent contract that will deploy other contracts on request with different parameters. I came across the "new" keyword which seemed like a perfect choice.
But when I am trying to deploy the parent contract and deploy child contracts from it, the same parent is getting deployed again.
I am writing the contract on remix and using Ganache.
The code for the contract is as below:
pragma solidity ^0.5.1;
contract Factory {
address[] public newContracts;
function createContract (string memory name) public{
address newContract = address(new MyContract(name));
newContracts.push(newContract);
}
}
contract MyContract {
string public Name;
constructor (string memory name) public {
Name = name;
}
}