Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jun 13, 2024
2 parents 308d0a9 + 677fc13 commit 3dd8a10
Show file tree
Hide file tree
Showing 263 changed files with 452 additions and 518 deletions.
21 changes: 0 additions & 21 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

15 changes: 0 additions & 15 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

15 changes: 0 additions & 15 deletions .github/ISSUE_TEMPLATE/improvement.md

This file was deleted.

15 changes: 0 additions & 15 deletions .github/ISSUE_TEMPLATE/typo_report.md

This file was deleted.

2 changes: 1 addition & 1 deletion 01_HelloWeb3/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
2 changes: 1 addition & 1 deletion 02_ValueTypes/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
2 changes: 1 addition & 1 deletion 03_Function/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
2 changes: 1 addition & 1 deletion 04_Return/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
2 changes: 1 addition & 1 deletion 05_DataStorage/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
2 changes: 1 addition & 1 deletion 06_ArrayAndStruct/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---
这一讲,我们将介绍`Solidity`中的两个重要变量类型:数组(`array`)和结构体(`struct`)。
Expand Down
2 changes: 1 addition & 1 deletion 07_Mapping/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
2 changes: 1 addition & 1 deletion 08_InitialValue/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
2 changes: 1 addition & 1 deletion 09_Constant/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---
这一讲,我们介绍Solidity中和常量相关的两个关键字,`constant`(常量)和`immutable`(不变量)。状态变量声明这两个关键字之后,不能在初始化后更改数值。这样做的好处是提升合约的安全性并节省`gas`
Expand Down
2 changes: 1 addition & 1 deletion 10_InsertionSort/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---
这一讲,我们将介绍`Solidity`中的控制流,然后讲如何用`Solidity`实现插入排序(`InsertionSort`),一个看起来简单,但实际上很容易写出`bug`的程序。
Expand Down
2 changes: 1 addition & 1 deletion 11_Modifier/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
2 changes: 1 addition & 1 deletion 12_Event/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
2 changes: 1 addition & 1 deletion 13_Inheritance/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---
这一讲,我们介绍`Solidity`中的继承(`inheritance`),包括简单继承,多重继承,以及修饰器(`Modifier`)和构造函数(`Constructor`)的继承。
Expand Down
4 changes: 2 additions & 2 deletions 14_Interface/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

这一讲,我们用`ERC721`的接口合约为例介绍`Solidity`中的抽象合约(`abstract`)和接口(`interface`),帮助大家更好的理解`ERC721`标准。

## 抽象合约

如果一个智能合约里至少有一个未实现的函数,即某个函数缺少主体`{}`中的内容,则必须将该合约标为`abstract`,不然编译会报错;另外,未实现的函数需要加`virtual`,以便子合约重写。拿我们之前的[插入排序合约](https://github.com/AmazingAng/WTFSolidity/tree/main/10_InsertionSort)为例,如果我们还没想好具体怎么实现插入排序函数,那么可以把合约标为`abstract`,之后让别人补写上。
如果一个智能合约里至少有一个未实现的函数,即某个函数缺少主体`{}`中的内容,则必须将该合约标为`abstract`,不然编译会报错;另外,未实现的函数需要加`virtual`,以便子合约重写。拿我们之前的[插入排序合约](https://github.com/AmazingAng/WTF-Solidity/tree/main/10_InsertionSort)为例,如果我们还没想好具体怎么实现插入排序函数,那么可以把合约标为`abstract`,之后让别人补写上。

```solidity
abstract contract InsertionSort{
Expand Down
2 changes: 1 addition & 1 deletion 15_Errors/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
4 changes: 2 additions & 2 deletions 16_Overloading/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand All @@ -37,7 +37,7 @@ function saySomething(string memory something) public pure returns(string memory
}
```

最终重载函数在经过编译器编译后,由于不同的参数类型,都变成了不同的函数选择器(selector)。关于函数选择器的具体内容可参考[WTF Solidity极简入门: 29. 函数选择器Selector](https://github.com/AmazingAng/WTFSolidity/tree/main/29_Selector)
最终重载函数在经过编译器编译后,由于不同的参数类型,都变成了不同的函数选择器(selector)。关于函数选择器的具体内容可参考[WTF Solidity极简入门: 29. 函数选择器Selector](https://github.com/AmazingAng/WTF-Solidity/tree/main/29_Selector)

`Overloading.sol` 合约为例,在 Remix 上编译部署后,分别调用重载函数 `saySomething()``saySomething(string memory something)`,可以看到他们返回了不同的结果,被区分为不同的函数。

Expand Down
2 changes: 1 addition & 1 deletion 17_Library/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---
这一讲,我们用`ERC721`的引用的库合约`Strings`为例介绍`Solidity`中的库合约(`Library`),并总结了常用的库合约。
Expand Down
2 changes: 1 addition & 1 deletion 18_Import/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
2 changes: 1 addition & 1 deletion 19_Fallback/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
2 changes: 1 addition & 1 deletion 20_SendETH/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---
`Solidity`有三种方法向其他合约发送`ETH`,他们是:`transfer()``send()``call()`,其中`call()`是被鼓励的用法。
Expand Down
2 changes: 1 addition & 1 deletion 21_CallContract/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
6 changes: 3 additions & 3 deletions 22_Call/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

我们曾在[第20讲:发送ETH](https://github.com/AmazingAng/WTFSolidity/tree/main/20_SendETH)那一讲介绍过利用`call`来发送`ETH`,这一讲我们将介绍如何利用它调用合约。
我们曾在[第20讲:发送ETH](https://github.com/AmazingAng/WTF-Solidity/tree/main/20_SendETH)那一讲介绍过利用`call`来发送`ETH`,这一讲我们将介绍如何利用它调用合约。

## Call

`call``address`类型的低级成员函数,它用来与其他合约交互。它的返回值为`(bool, bytes memory)`,分别对应`call`是否成功以及目标函数的返回值。

- `call``Solidity`官方推荐的通过触发`fallback``receive`函数发送`ETH`的方法。
- 不推荐用`call`来调用另一个合约,因为当你调用不安全合约的函数时,你就把主动权交给了它。推荐的方法仍是声明合约变量后调用函数,见[第21讲:调用其他合约](https://github.com/AmazingAng/WTFSolidity/tree/main/21_CallContract)
- 不推荐用`call`来调用另一个合约,因为当你调用不安全合约的函数时,你就把主动权交给了它。推荐的方法仍是声明合约变量后调用函数,见[第21讲:调用其他合约](https://github.com/AmazingAng/WTF-Solidity/tree/main/21_CallContract)
- 当我们不知道对方合约的源代码或`ABI`,就没法生成合约变量;这时,我们仍可以通过`call`调用对方合约的函数。

### `call`的使用规则
Expand Down
2 changes: 1 addition & 1 deletion 23_Delegatecall/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
2 changes: 1 addition & 1 deletion 24_Create/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:

社区:[Discord](https://discord.gg/5akcruXrsk)[微信群](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[官网 wtf.academy](https://wtf.academy)

所有代码和教程开源在 github: [github.com/AmazingAng/WTFSolidity](https://github.com/AmazingAng/WTFSolidity)
所有代码和教程开源在 github: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)

---

Expand Down
Loading

0 comments on commit 3dd8a10

Please sign in to comment.