I have two contracts, TokenContract and DynamicContract. The latter is created dynamically.
I want to call a function of DynamicContract from TokenContract (receiveApproval). According to this question, what I need to do is this:
function ApproveAndCall(address dynContAddress, uint value){
DynamicContract dynamicContractInstance = DynamicContract(dynContAddress);
dynamicContractInstance.foo();
return true;
}
I have import "./DynamicContract.sol"; at the beginning of my TokenContract.
The thing is, I already have a constructor for DynamicContract and it takes a bunch of parameters. So I get a compilation error stating I don't have the right parameters.
I also tried using simply DynamicContract(dynContAddress).foo() but I get Member "foo" not found or not visible after argument-dependent lookup in address
EDIT:
Maybe I should use function ApproveAndCall(DynamicContract dynContAddress, ...){} instead of function ApproveAndCall(address dynContAddress, ...) if I want to use dynContAddress.foo(){}? What's the difference?
I think the problem might come from the fact that both contract call functions of the other, so both have import "./OtherContract.sol". Since one has to compile before the other there might be a problem (Solidity isn't as flexible as some other languages).
Could it be the problem? Then how could I solve it? (I don't think the contract is over complicated, I just want to pay for functions in token and transfer them to the address they belong to).
EDIT 2:
Actually I don't think that's the problem because when running truffle compile, I get Compiling .\contracts\DynamicContract.sol...and Compiling .\contracts\Factory.sol... before Compiling .\contracts\Token.sol... that gives the error. (member not found or not visible ...)