Skip to content

Instantly share code, notes, and snippets.

@PatrickAlphaC
Created July 14, 2022 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatrickAlphaC/c9898221af332b5ab976a33ef1734222 to your computer and use it in GitHub Desktop.
Save PatrickAlphaC/c9898221af332b5ab976a33ef1734222 to your computer and use it in GitHub Desktop.
Look at how msg.sender works across contracts
// 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