2

In the following the example of interaction between two contracts based on the example: Basic example of interaction between 2 contracts?

contract C1 {  
    function f1() returns(uint) {  
        return(10);   
    }
}

contract C2 {
    function f2(address addrC1) returns(uint) {  
        C1 c1 = C1(addrC1);  
        return c1.f1();  
    }
} 

Although I have been able to successfully do this form of interaction on the online compiler and at the console prompt, I don't see a way to do the same using the Mist wallet. I tried deploying C1 first and was able to get the contract address and ABI. Now, when i tried to deploy just the contract C2, I get an error during compilation saying:

source not found, file not compiled initially

Even after adding the instruction:

import "C1"

I get the error:

source not found, file not compiled initially.

Any suggestions as to how this can be done on Mist? I tried importing the contract as well, but that is similar to adding an existing contract to interact with, and have not been able to make progress after.

skarred14
  • 945
  • 1
  • 9
  • 18
  • the only way i got this to work is deploy C1 first, get the contract address; then paste code for both C1 and C2 in the window, then deploy C2. After this step, execute f2 in C2 - this by itself cannot be sufficient to check whether the value 10 is returned or not. Only way i have found is to track this interaction by means of an event during the invocation of f2, which can then be observed as an event on the contract C2's page in the wallet. Not sure if this is the right mechanism – skarred14 Oct 25 '16 at 03:30
  • missed the 5 min mark. here is the continuation of the comment:
    • if i replace C1 with X1 in second step (deploying C2 while having X1 in place of C1, and executing f2, still returns 10 in the event tracker. How does C2 determine which instance to call - C1 or X1?
    – skarred14 Oct 25 '16 at 03:38

0 Answers0