5

I have two cntracts with one calling the other. The first is

contract A_int
{
    event called(string str,uint ts,address addr,string tr);
    function callme(address addr,uint ts,string tr)
    {
        called("called me",ts,addr,tr);
    }
    function kill()
        { 
        suicide(msg.sender);
        }
}

and another contract which calls this contract

contract caller_tracker_string
{
    address curr_tracker;
    address owner; 
    function change_contract(address addr)
    {
        curr_tracker=addr;
    }
    function caller_tracker_string(address current_trcker)
    {
        owner=tx.origin;
        curr_tracker=current_trcker;        
    }
    function adduser(address usr_new,uint ts,string tr)
    {
        curr_tracker.call(bytes4(sha3("callme(address,uint256,string)")),usr_new,ts,tr);
    }
    function kill()
        { 
        suicide(owner);
        }
}

The issue I am facing is that the string argument is not getting logged in contract A's log event. why could that be happening?

1

You would do well to tidy up your code with short expressive names. You would then notice that your presumed constructor function caller_tracker has a name that does not match that of your contract caller_tracker_string. This results in curr_tracker being always 0, so A_int is never called.

  • Did spelling the constructor correctly fix your issue? – Xavier Leprêtre B9lab Sep 19 '16 at 16:12
  • No. I am still not able to call the second contract correctly. It is still logging empty string for tr value – Aravind_R Sep 19 '16 at 20:38
  • I was finally able to call another contract using the below method. A_int a=A_int(curr_tracker); a.callme(addr,ts,"hi");. But still dont know why the above method does not work. – Aravind_R Sep 23 '16 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.