Value of msg.sender in call to inherited external function

by Luis Schliesske   Last Updated October 09, 2019 17:28 PM - source

I found this in the official solidity docs.

The values of all members of msg, including msg.sender and msg.value can change for every external function call. This includes calls to library functions.

The "can change for every external function call" is too vague for me.

Does anyone know when it does change for an external function call?

My concrete example:

contract A {
    function foo() external {emit EmitMsgSender(msg.sender);}

contract B is A {
    function bar() external {
        // 3 ways of doing the same thing;  // does this work and who will be msg.sender?;  // does this work and who will be msg.sender?;  // does this work and who will be msg.sender? 

Please take all the code as is => in the 3 notations I am NOT talking to another deployed contract instance. With all 3 ways I want to showcase 3 (different but same) ways of calling external functions (inherited ones in this case) on a contract from inside (internally) that same contract. The 3 ways basically just vary in their scope or explicitness I believe.

Back to my main question: Who is the msg.sender emitted in the EmitMsgSender event emitted by the call to A/this/ in my example? Is it contract B's address payable or is it the address that sent the tx to

By the way, it would make my life easier, if it were the original caller of the function, and not B's address.

Thanks for your help!

Related Questions

Inherited constructors execution order

Updated October 31, 2017 16:28 PM

Solidity and multiple inheritance

Updated April 12, 2018 16:28 PM