0

I am looking for some help here.

I would like to know how (using matrix) that I could call a function of an already deployed contract on the Ropsten net and get the return value. I have searched a lot and not found anything about how to do this.

I know the name of the function and the address of the contract.

contract Test2 {

    function Test2s() public{  
        int t = test() ;  
    }

    function test() public returns (int c){
        address addr = address(0xFbdCc***************************6 );  
         bytes4 sig = bytes4(keccak256("function()")); //Function signature

         assembly {
        let x := mload(0x40)   //Find empty storage location using "free memory pointer"
        mstore(x,sig) //Place signature at begining of empty storage 

        let success := call(      
                            500000, //50k gas
                            addr, //To addr
                            0,    //No value
                            x,    //Inputs are stored at location x
                            0x00, //Inputs are 68 bytes long
                            x,    //Store output over input (saves space)
                            0x20) //Outputs are 32 bytes long

        c := mload(x) //Assign output value to c
        mstore(0x40,add(x,0x44)) // Set storage pointer to empty space
    }
    }
}

Ive managed to get htis on the network but I keep getting internal errors even though the contract concludes. Any asistance would be so appreciated.

Thanks!

  • 1. What is matrix? 2. What does "I keep getting internal errors" mean? 3. What does "the contract concludes"? – goodvibration Feb 21 at 14:28
  • You are passing zero bytes as input 0x00, //Inputs are 68 bytes long (comment is wrong obviously). That should invoke the fallback function of the target contract. Also you have a function named Test2s that is too similar to the contract name Test2 so check if that is an error. – Ismael Feb 21 at 15:47

Your Answer

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

Browse other questions tagged or ask your own question.