Skip to content

Commit

Permalink
修正接口必须被实现的规则
Browse files Browse the repository at this point in the history
Interface 可以被 abstract contract 继承但不实现,因此改了这一条规则为“非抽象合约”。

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface TestInterface {
    function test() external;
}

abstract contract TestContract is TestInterface {}

```
  • Loading branch information
charliex2 committed May 14, 2023
1 parent 1727039 commit 6e1b69f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 14_Interface/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract contract InsertionSort{
2. 不能包含构造函数
3. 不能继承除接口外的其他合约
4. 所有函数都必须是external且不能有函数体
5. 继承接口的合约必须实现接口定义的所有功能
5. 继承接口的非抽象合约必须实现接口定义的所有功能

虽然接口不实现任何功能,但它非常重要。接口是智能合约的骨架,定义了合约的功能以及如何触发它们:如果智能合约实现了某种接口(比如`ERC20``ERC721`),其他Dapps和智能合约就知道如何与它交互。因为接口提供了两个重要的信息:

Expand Down

0 comments on commit 6e1b69f

Please sign in to comment.