My code works with compiler 0.4.25 but not with the latest version. I want to keep track of every "Contract 2" that "Contract 1" create.
Contract 1
uint public countContract;
address[] public deployedContracts;
function createContract(string memory _name)
public{
address newContract = new Contract2(countContract++, _name);
deployedContracts.push(newContract);
}
Contract 2
uint public id;
string public name;
constructor(uint _id, string memory _name)
public{
id = _id;
name = _name;
}
The error I am receiving on Remix is:
browser/temp.sol:9:5: TypeError: Type contract Contract2 is not implicitly convertible to expected type address. address newContract = new Contract2(countContract++, _name);