1

Who is the msg.sender in emitted event by calling callMe method on contract D?

pragma solidity 0.8.10;

contract A {

    event LogMsgSender(address who);

    function callMe() public {
        emit LogMsgSender(msg.sender);
    }
}

contract B {

    function callMe(address a) public {
        a.delegatecall(
            abi.encodeWithSignature("callMe()")
        );
    }
}

contract C {

    function callMe(address a, address b) public {
         b.delegatecall(
            abi.encodeWithSignature("callMe(address)",a)
        );
    }
}

contract D {

    function callMe(address a, address b, address c) public {
        c.delegatecall(
            abi.encodeWithSignature("callMe(address,address)",a,b)
        );
    }
}

1 Answer 1

3

It's the original msg.sender (the one who calls callMe on contract D) because msg.sender context are all the same in D,C,B,A. For example, user having an account 0x1111... calls callMe(a,b,c) on D, the msg.sender logged on contract A (address a) will be 0x1111... Read more about delegate calls on Solidity Document

1
  • thank you for your answer, I just asked this question because I could not find the answer untill run the above example.
    – 0xbeny
    Commented Jan 3, 2023 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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