【发布时间】:2020-09-27 02:01:10
【问题描述】:
我有以下两份合同:
contract A {
uint256 someData = 3
function foo() public view returns (uint256) {
// return something based on msg.sender and someData
}
}
contract B {
A public a;
function bar() public {
// I'd like to call a.foo with msg.sender for this context
uint256 ret = a.foo()
}
}
如前所述,我想在B 中使用msg.sender 在B 的上下文中调用a.foo,但我想在A 的存储中使用someData。这意味着使用 delegatecall 将不起作用,因为它会使用 B 的存储空间来调用 A.foo。
有什么办法可以在这里做我想做的事吗?问题在于“真正的”A 已经部署在主网上,我无法更改它的编写方式。
【问题讨论】: