I have a smart contract that is making two (a token and a crowdsale) other contracts.
mapping (uint => myStruct) myMapping;
function start(uint uuid) public returns (bool) {
address tokenAddress = new Token();
address crowdsaleAddress = new Crowdsale();
Token(tokenAddress).addMinter(crowdsaleAddress);
myMapping[uuid].addr_t = tokenAddress;
myMapping[uuid].addr_c = crowdsaleAddress;
return true;
}
The issue I'm running into is that this basically works some times. When I call it a few times in a row errors start to be thrown. It works the first time or the last time.
Are tokenAddress
and crowdsaleAddress
not being set by the time that they are being passed into Token(tokenAddress).addMinter(crowdsaleAddress)
.
I tried to debug this using truffle/remix debugger, but when contracts make other contracts, things get pretty crazy.
Is there anything wrong with this code? tokenAddress
and crowdsaleAddress
are address and not txhashes? Are tokenAddress
and crowdsaleAddress
valid immediately or do they take time to mine? I'm pretty confused about where the problem is so any help is appreciated.
Token(tokenAddress).addMinter(crowdsaleAddress);
save the address to the blockchain? Aren'ttokenAddress
andcrowdsaleAddress
supposed to be temporary?