在浏览坚实的文档时,我注意到在程序集中可用的指令:
呼叫者():呼叫发件人(不包括
delegatecall)
博士们所说的“排除delegatecall”是什么意思?如果合同A委托调用合同B,caller()不会返回合同A的地址,而是会返回调用A的原始EOA吗?(我知道msg.sender在这种情况下是一样的)
发布于 2022-09-07 14:29:25
它返回一个空号码(0x000.0000)。
您可以自己检查它,在Remix上运行以下代码:
contract Stub {
event Caller(uint caller);
function testCaller() public {
uint caller;
assembly { caller := caller() }
emit Caller(caller);
}
}
contract Delegator {
// where stub must be the address of the above contract.
function testDelegatecall(address stub) public returns (bool) {
(bool success,) = stub.delegatecall(
abi.encodeWithSignature("testCaller()")
);
return success;
}
}https://ethereum.stackexchange.com/questions/111270
复制相似问题