Im Trying to create a DAPP with two contracts generating assets. One is acting as the "factory" for the other contracts. From the latter I try to call a function in the factory without knowing its address yet, therefore I want to pass it in as an argument. This throws an error in Remix because that contract obviously doesn't exist yet.
To simplify the situation think about this scenario in Remix (both contracts are written in the same file):
contract AssetFactory{
address[] deployedAssets;
function createAsset(string name) public {
address newAsset = new Asset(name);
deployedAssets.push(newAsset);
return newAsset;
}
}
contract Asset{
string name;
function Asset(string name) public{
name = name;
}
function ModifyAssetAndCreateNew(string name, address factory){
factory.createAsset(name);
name = name;
}
}
Any Ideas or other approaches? I realize that the idea behind the above contract doesn't make much sense in this example but i tried to keep it as short as possible.
Thank you!