5 用自身地址进行委托调用

在uniswapV3 的 SwapRouter02 https://etherscan.io/address/0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45#code#F61#L14

abstract contract Multicall is IMulticall {
    /// @inheritdoc IMulticall
    function multicall(bytes[] calldata data) public payable override returns (bytes[] memory results) {
        results = new bytes[](data.length);
        for (uint256 i = 0; i < data.length; i++) {
            (bool success, bytes memory result) = address(this).delegatecall(data[i]);

            if (!success) {
                // Next 5 lines from https://ethereum.stackexchange.com/a/83577
                if (result.length < 68) revert();
                assembly {
                    result := add(result, 0x04)
                }
                revert(abi.decode(result, (string)));
            }

            results[i] = result;
        }
    }
}
(bool success, bytes memory result) = address(this).delegatecall(data[i]);

这一句为什么不用call 是有什么特殊的设计吗

请先 登录 后评论

最佳答案 2023-01-13 15:31

这样 call , 那样 msg.sender 还是来自于用户. 而不是 合约自己.

请先 登录 后评论

其它 0 个回答

  • 1 关注
  • 0 收藏,1072 浏览
  • soso 提出于 2023-01-13 11:55