0

Suppose I have contract A. Contract B inherits Contract A. Suppose updateB() is called in contract A from an EOA. Now inside update(), a function in contract B is called. Will msg.sender be that of the EOA or will it be address(this), the address of the smart contract ?

Import ./IContractB

Contract A {

     function updateB() external {
       IContractB(address(this)).update()
     }
}

Contract B is Contract A {

    function update() external {
      require(msg.sender == address(this);
      //logic
    }

}

1 Answer 1

2

when updateB() is called on Contract A from an EOA, msg.sender within updateB() is the EOA. However, when Contract A then calls update() in Contract B using IContractB(address(this)).update(), the msg.sender within the update() function is set to the address of Contract A, because Contract A is the one executing the call to update().

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.