// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;
pragma abicoder v2;
import '@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol';
import '@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol';
contract SwapExamples {
ISwapRouter public immutable swapRouter;
constructor(ISwapRouter _swapRouter) {
swapRouter = _swapRouter;
}
}构造函数在合同创建过程中期望得到什么?它是否要求一个地址,并隐式地将其转换到接口类型中?还是在合同创建过程中传递接口类型之类的东西?
发布于 2022-01-07 08:36:50
实体中的接口和契约类型只是围绕address的编译时间包装器。如果您查看为您的代码生成的abi文件,您将看到所期望的参数类型是address。实际上,生成的字节码不会对此地址执行任何类型检查。如果您想检查特定地址是否实现了接口,我建议您查看EIP-165。
https://ethereum.stackexchange.com/questions/118208
复制相似问题