0

I want to call a Contract1's function from Contract2. I know the way i've tried is deprecated, but i want to understand. This is why i've set a very old solidity version with the pragma directive.

I do not understand why f1 and f2 are still equals to zero when i call test_call3 function...

Any idea ?

Thanks

pragma solidity 0.4.11;

contract Contract1 
{
  uint public f1;
  uint public f2;
  
  function myfunction(uint param1,uint param2) external 
  {
      f1 = param1;
      f2 = param2;
  }
}

contract Contract2  
{
  Contract1 c = Contract1( <deployment_address_of_Contract1>);

  bool public success;

  function test_call3() public
  {
       success = address(c).call(  bytes4(keccak256("myfunction(uint256,uint256)")),  400, 500);
  }
}
3
  • Do you call function test_call3 in transaction? – Mad Jackal Jan 3 at 16:57
  • 1
    In remix it does work as expected. – Ismael Jan 3 at 17:15
  • Yes i have called test_call3() function and i've done that on remix... Strange – Bob5421 Jan 3 at 19:19

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.