1

I am trying to call contract A.fun_A() via Contract C

contract A{
   function fun_A(address tenant, uint itemId){
     //Here the msg.sender should be msg.sender in C
     require(msg.sender == ownerOf(itemId));
     ....
   }
}

contract B is A{
    ...
}

contract C {
    B contract_B;
    constructor(address deployer_B){
        contract_B = B(deployer_B);
    }

    function fun_A(address tenant, uint itemId){
       //-------???? How to invoke fun_A where msg.sender should be same as in C
    }
}

Try 1:

(bool status1, bytes memory data1) = address(contract_B)
     .delegatecall(abi.encodePacked(bytes4(keccak256("fun_A(address, uint256)")), tenant, itemId));

Try 2:

(bool status1, bytes memory data1) = address(contract_B)
      .delegatecall(abi.encodeWithSignature("fun_A(address, uint256)", tenant, itemId));

Both didnt work.. I would like to invoke the inheritated functions through child contract where msg.sender should be same as in Contract C. is there any other way to pass address as an argument via delegatecall?

Update:

Thanks. removed space yet didnt solved. that did worked for the function in contract B.. but its not making call to the function in contract A.

https://gist.github.com/Kowsi/147cf728ec0da29bfbd9c7a5977b7d2c#file-dealerlessmarket-sol .. Line 123 is working fine.. Line 126 & 137 are not working.. Here I am trying to implement ERCX - ERC2615

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.