0

我有以下两个合同:


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()  
  }
}

如前所述,我想在 in 的上下文中调用a.foo,但B我想在 A 的存储中使用。这意味着 using不起作用,因为它会使用 B 的存储进行调用。msg.senderBsomeDatadelegatecallA.foo

有什么办法可以在这里做我想做的事吗?问题与“真实”A已经部署在主网上的事实有关,我无法改变它的编写方式。

4

1 回答 1

0

I don't think this is possible as of now. I just faced the same issue but not able to find any solution. It would be better if you can create a new contract from scratch and deploy it again on mainnet by transferring all the tokens to new address.

于 2020-09-30T04:11:24.800 回答