I want to create a contract that can create contract itself
I find something like this
pragma solidity ^0.5.0;
contract DaughterContract {
string public name;
uint public age;
constructor(
string memory _daughtersName,
uint _daughtersAge
)
public
{
name = _daughtersName;
age = _daughtersAge;
}
}
contract MomContract {
string public name;
uint public age;
DaughterContract public daughter;
constructor(
string memory _momsName,
uint _momsAge,
string memory _daughtersName,
uint _daughtersAge
)
public
{
daughter = new DaughterContract(_daughtersName, _daughtersAge);
name = _momsName;
age = _momsAge;
}
}
but it's only working when I hardcode Daughter contract And it only works once
I want to create a mother contract that is able to create multiple daughters by calling function
Something like this
whats should be change