ethereum - 是否可以使用其存储但传递 msg.sender 以可靠的方式调用合约?
问题描述
我有以下两个合同:
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.sender
B
someData
delegatecall
A.foo
有什么办法可以在这里做我想做的事吗?问题与“真实”A
已经部署在主网上的事实有关,我无法改变它的编写方式。
解决方案
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.
推荐阅读
- npm - 在 bitbucket-pipeline 中运行 nuxt.js 会引发“未定义”错误
- c# - 我决定将两个场景都加载到层次结构中,因为在它们之间引用变量更容易。我怎样才能重新开始一个新游戏?
- python-3.x - 通过python将.mat文件扩展名图像转换为.jpg
- python - 从响应中获取空文件并且无法将文件保存在 django 模型类中
- linux - 如何将目录中的多个 .dav 文件转换为 .mp4
- c# - 类型未标记为可序列化
- java - 如何使用类的字符串属性在 java 中引用该类?
- android - 如何在带有 gradle 插件 3.5.1 的 android 库中使用 productFlavors
- apache-kafka - kafka mongo-db connector KCQL 支持配置--分布式
- java - 在 Eclipse Che 中调试 Java 测试