Created
July 14, 2022 13:45
-
-
Save PatrickAlphaC/c9898221af332b5ab976a33ef1734222 to your computer and use it in GitHub Desktop.
Look at how msg.sender works across contracts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
interface IMo{ | |
function callMeDifferentContract() external returns(address); | |
} | |
contract Me{ | |
address public senderOne; | |
address public senderTwo; | |
address public senderThree; | |
function callMe(address moAddress) public{ | |
senderOne = msg.sender; | |
senderTwo = callMeSameContract(); | |
senderThree = IMo(moAddress).callMeDifferentContract(); | |
} | |
function callMeSameContract() public returns(address){ | |
return msg.sender; | |
} | |
} | |
contract Mo{ | |
function callMeDifferentContract() public view returns(address){ | |
return msg.sender; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment