What are some ways to get address of contract which called a contract ?
For example, does msg.sender pass the address of the account which invoked callCanOnlyBeCalledByB(), or the address of B ?
contract A {
address B; //set by other mechanism
function canOnlyBeCalledByB() external {
if(msg.sender == B) { do thing }
}
}
contract B {
address owner; //set by other mechanism
address A; //set by other mechanism
function callCanOnlyBeCalledByB() {
if(msg.sender != owner) throw;
bytes4 functionSig = bytes4(sha3("canOnlyBeCalledByB()"));
A.call(functionSig);
}
}
msg.sendercorrectly as explained by @Edmund. Related: http://ethereum.stackexchange.com/questions/1891/whats-the-difference-between-msg-sender-and-tx-origin – eth Oct 17 '16 at 06:59