Skip to content

Commit

Permalink
publish review 18-20
Browse files Browse the repository at this point in the history
  • Loading branch information
AmazingAng committed May 22, 2023
1 parent 789922f commit 6a79b93
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion 18_Import/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tags:

-----

`solidity`支持利用`import`关键字导入其他合约中的全局符号(简单理解为外部源代码),让开发更加模块化。一般不具体指定则将导入文件的所有全局符号到当前全局作用域中
在Solidity中,`import`语句可以帮助我们在一个文件中引用另一个文件的内容,提高代码的可重用性和组织性。本教程将向你介绍如何在Solidity中使用`import`语句

## `import`用法

Expand Down
2 changes: 1 addition & 1 deletion 19_Fallback/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tags:
我们这一讲主要讲接收ETH的情况。

## 接收ETH函数 receive
`receive()`只用于处理接收`ETH`。一个合约最多有一个`receive()`函数,声明方式与一般函数不一样,不需要`function`关键字:`receive() external payable { ... }``receive()`函数不能有任何的参数,不能返回任何值,必须包含`external``payable`
`receive()`函数是在合约收到`ETH`转账时被调用的函数。一个合约最多有一个`receive()`函数,声明方式与一般函数不一样,不需要`function`关键字:`receive() external payable { ... }``receive()`函数不能有任何的参数,不能返回任何值,必须包含`external``payable`

当合约接收ETH的时候,`receive()`会被触发。`receive()`最好不要执行太多的逻辑因为如果别人用`send``transfer`方法发送`ETH`的话,`gas`会限制在`2300``receive()`太复杂可能会触发`Out of Gas`报错;如果用`call`就可以自定义`gas`执行更复杂的逻辑(这三种发送ETH的方法我们之后会讲到)。

Expand Down

0 comments on commit 6a79b93

Please sign in to comment.