2

有关uniswap V2 工厂合约的疑问

 2 years ago
source link: https://learnblockchain.cn/question/2715
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
有关uniswap V2 工厂合约的疑问

有关uniswap V2 工厂合约的疑问

UniswapV2Factory 合约中 contract UniswapV2Factory is IUniswapV2Factory{ } UniswapV2Factory继承了IUniswapV2Factory接口 IUniswapV2Factory中有八个未实现方法

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

UniswapV2Factory中只实现了其中四种方法 allPairsLength createPair setFeeTo setFeeToSetter 如果继承了接口却不把方法完全实现,那UniswapV2Factory工厂合约不就是个抽象合约吗? 为什么抽象合约还能通过编译并部署?

最佳答案 1天前

另外的是 public 的状态变量,因为 public 的状态变量会自动生成对应名称的 getter 函数, 可参考文档:

https://learnblockchain.cn/docs/solidity/contracts.html#getter-functions

Tiny熊 - 布道者
擅长:智能合约,以太坊 | 采纳率 39% | 回答于 1天前

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK