5 如何获取外部合约调用本合约时的签名?

这是一个外部合约:

// 合约A,是一个已经部署好的外部合约,我无法控制
interface ITestB {
    function testFuncB() external returns (bool);
}

contract TestA {
    ITestB private testB;
    function testFuncA() public returns (bool) {
        testB.testFuncB();
    }
}

这是我写的自己的合约,我想在注释的位置,获取外部调用时的 msg.sig

// 另一个我自己写的合约,与合约A部署在不同地址
contract TestB {
    function testFuncB() public returns (bool) {
        // 我想在这里获取到 testFuncA 的方法签名(msg.sig)
    }
}

请问是否可以做到呢?如果能,应该如何做呢?

请先 登录 后评论

1 个回答

Tiny熊 - 布道者
  擅长:智能合约,以太坊
请先 登录 后评论
  • 1 关注
  • 0 收藏,1956 浏览
  • 提出于 2020-10-01 22:18

相似问题