From d361979769b28cad0653c2e5769758a748d8be20 Mon Sep 17 00:00:00 2001 From: jaxrunboo Date: Mon, 30 Sep 2024 00:04:11 +0800 Subject: [PATCH 1/8] import --- jaxrunboo.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/jaxrunboo.md b/jaxrunboo.md index 1570bc9e..53639fd6 100644 --- a/jaxrunboo.md +++ b/jaxrunboo.md @@ -398,4 +398,34 @@ function getString2(uint256 _number) public pure returns(string memory){ ### +### 2024.09.28 + +#### 导入 + +关键词 import + +导入方式: + +1. 通过文件的相对位置导入 +2. 通过全局符号,导入合约特定的全局符号 +3. 通过网址引入 +4. 通过npm的目录导入 + +```solidity + +//1 +import './3_Ballot.sol'; +//2 +import {Ballot} from './3_Ballot.sol'; +//3 +import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol'; +//4 +import '@openzeppelin/contracts/access/Ownable.sol'; + +``` + +接下来就可以很简单的像使用库一样,通过using for语句或者直接静态函数引用的方式来使用。 + +### + From 764159413a5bd50e8c487ffad62c4f80857c036c Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 29 Sep 2024 16:04:59 +0000 Subject: [PATCH 2/8] Update commit status table --- README.md | 191 +++++++++++++++++++++++++++--------------------------- 1 file changed, 96 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index eb244e06..5e4035b8 100644 --- a/README.md +++ b/README.md @@ -78,135 +78,135 @@ | Solidity· Name | 9.23 | 9.24 | 9.25 | 9.26 | 9.27 | 9.28 | 9.29 | 9.30 | 10.01 | 10.02 | 10.03 | 10.04 | 10.05 | 10.06 | 10.07 | 10.08 | 10.09 | 10.10 | 10.11 | 10.12 | 10.13 | 10.14 | 10.15 | 10.16 | | ------------- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | -| Eric | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| 0xRory | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Eric | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| 0xRory | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | Ramsay | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| jaxrunboo | ✅ | ✅ | ⭕️ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | -| danger | ✅ | ✅ | ⭕️ | ✅ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | -| Robin | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| jaxrunboo | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| danger | ✅ | ✅ | ⭕️ | ✅ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | +| Robin | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | DX3906 | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| FFFFourwood | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| FFFFourwood | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | YSKMQAQ | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | CHENkai8385 | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| Ariel | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| Aris | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| vic | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | +| Ariel | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| Aris | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| vic | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | leoshi | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | -| lucky-ti | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | -| awaqawaqawaq | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | -| wayhome | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| lileilei | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| Ric-Li-C | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| He​len | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | | | | | | | | | | | | | | | | | | | -| button | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | -| Jackchou | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| nghdavid | ✅ | ✅ | ⭕️ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | -| saneryee | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | +| lucky-ti | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | | | | | | | | | | | | | | | | | | +| awaqawaqawaq | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | +| wayhome | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| lileilei | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| Ric-Li-C | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| He​len | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | +| button | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | | | | | | | | | | | | | | | | | | +| Jackchou | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| nghdavid | ✅ | ✅ | ⭕️ | ✅ | ✅ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | +| saneryee | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | isparkyou | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | -| Clad | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Clad | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | aaronchou | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| eddie | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| qiaopengjun | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| Sponge | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | +| eddie | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| qiaopengjun | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| Sponge | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | | | | | | | | | | | | | | | | | | | road | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | -| ruoshui | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| tom | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| ruoshui | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| tom | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | Pumpkin12699 | ✅ | ⭕️ | ⭕️ | ✅ | ❌ | | | | | | | | | | | | | | | | | | | | -| jasonch1u | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| Mud-Yun | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | -| syskey | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| jasonch1u | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Mud-Yun | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | | | | | | | | | | | | | | | | | | +| syskey | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | July | ✅ | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | -| Yolanda | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| kaka | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Yolanda | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| kaka | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | Thurendous | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | | | | | | | | | | | | | | | | | | om14 | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | 0xwangyi | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| JB | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | -| rorozn | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| JB | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | +| rorozn | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | ColtraneBE | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| whw2025 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| Ronas | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| whw2025 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Ronas | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | cadeyu | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| xiaodongQ | ✅ | ✅ | ⭕️ | ⭕️ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | +| xiaodongQ | ✅ | ✅ | ⭕️ | ⭕️ | ✅ | ✅ | ❌ | | | | | | | | | | | | | | | | | | | wyeeeh | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| affe | ✅ | ✅ | ⭕️ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | | +| affe | ✅ | ✅ | ⭕️ | ✅ | ⭕️ | ✅ | ❌ | | | | | | | | | | | | | | | | | | | breeze | ✅ | ✅ | ⭕️ | ✅ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | -| Anzhe | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| Haoder | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Anzhe | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Haoder | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | bo | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| LikKee | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| Jason | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| realgu | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| CraigC | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| LikKee | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| Jason | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| realgu | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| CraigC | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| LikKee | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Jason | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| realgu | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| CraigC | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| LikKee | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Jason | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| realgu | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| CraigC | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | Jake | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| nate | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | | | | | | | | | | | | | | | | | | | -| MaggieS | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| kurt | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | +| nate | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | +| MaggieS | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| kurt | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | Tony_Tsai | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| spn | ✅ | ⭕️ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| YuanboXie | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | +| spn | ✅ | ⭕️ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| YuanboXie | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | | | | | | | | | | | | | | | | | | | shiroshiro | ✅ | ✅ | ⭕️ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | | MrK | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | -| Azleal | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| JakeDu | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| Aleng | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | +| Azleal | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| JakeDu | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| Aleng | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | 0xbkbk | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| Yuchen | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Yuchen | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | cthzhw | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | Ray | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | kongfu | ✅ | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | -| Pearl | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | -| WaterBoat | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| RockChang | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| cxk228922 | ✅ | ✅ | ✅ | ⭕️ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | -| Gsus4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| 0xfu | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| ChenBingWei1201 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | +| Pearl | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | +| WaterBoat | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| RockChang | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| cxk228922 | ✅ | ✅ | ✅ | ⭕️ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | +| Gsus4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| 0xfu | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| ChenBingWei1201 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | Arvid | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| JLsgl | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| Judy | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| supergu | ✅ | ✅ | ✅ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | | +| JLsgl | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Judy | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| supergu | ✅ | ✅ | ✅ | ✅ | ⭕️ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | Dida | ⭕️ | ⭕️ | ✅ | ✅ | ❌ | | | | | | | | | | | | | | | | | | | | -| baiyazi | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| MrF | ✅ | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| Lisa | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | -| baiyazi | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| MrF | ✅ | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| Lisa | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | +| baiyazi | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| MrF | ✅ | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Lisa | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | | | | | | | | | | | | | | | | | | +| baiyazi | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| MrF | ✅ | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Lisa | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | | | | | | | | | | | | | | | | | | | sjlin | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | | whynottellme | ✅ | ✅ | ⭕️ | ✅ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | liaojiamin | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| k66inthesky | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| arieswang | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| arttseng | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| 0x3f3f3f3f3f3f | ✅ | ✅ | ✅ | ⭕️ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | +| k66inthesky | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| arieswang | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| arttseng | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| 0x3f3f3f3f3f3f | ✅ | ✅ | ✅ | ⭕️ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | | terry950201 | ✅ | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | 0xruss13 | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| YuKirasawa | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| Rumbia | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| 4-in-truth | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | | | | | | | | | | | | | | | | | | | -| Johnny | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | -| llt | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| Arvid-io | ✅ | ✅ | ✅ | ⭕️ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | -| Univ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| Passi0n1 | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| keien | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| 0xiaoyu | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| YuKirasawa | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Rumbia | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| 4-in-truth | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | +| Johnny | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | | | | | | | | | | | | | | | | | | +| llt | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Arvid-io | ✅ | ✅ | ✅ | ⭕️ | ✅ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | +| Univ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| Passi0n1 | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| keien | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| 0xiaoyu | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | Angie | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | -| YuKirasawa | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| Rumbia | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| 4-in-truth | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | | | | | | | | | | | | | | | | | | | -| Johnny | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | -| llt | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| Arvid-io | ✅ | ✅ | ✅ | ⭕️ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | -| Univ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| Passi0n1 | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | -| keien | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| 0xiaoyu | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| YuKirasawa | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Rumbia | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| 4-in-truth | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | +| Johnny | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | | | | | | | | | | | | | | | | | | +| llt | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Arvid-io | ✅ | ✅ | ✅ | ⭕️ | ✅ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | +| Univ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| Passi0n1 | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| keien | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| 0xiaoyu | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | Angie | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | | MichaelChen | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | @@ -1010,6 +1010,7 @@ + <<<<<<< HEAD From 4fd089bfbdf661f3272db80837686f92e8aa7b89 Mon Sep 17 00:00:00 2001 From: jaxrunboo Date: Mon, 30 Sep 2024 00:05:48 +0800 Subject: [PATCH 3/8] date change --- jaxrunboo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jaxrunboo.md b/jaxrunboo.md index 53639fd6..9ecb393e 100644 --- a/jaxrunboo.md +++ b/jaxrunboo.md @@ -398,7 +398,7 @@ function getString2(uint256 _number) public pure returns(string memory){ ### -### 2024.09.28 +### 2024.09.29 #### 导入 From 796c9a82ab05a4247ace672294ff7c3e0c22c7fc Mon Sep 17 00:00:00 2001 From: YuChen <102439830+Dandelionlibra@users.noreply.github.com> Date: Mon, 30 Sep 2024 00:06:41 +0800 Subject: [PATCH 4/8] Create 9/30.md --- Yuchen.md | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/Yuchen.md b/Yuchen.md index 11821263..1c9815be 100644 --- a/Yuchen.md +++ b/Yuchen.md @@ -667,6 +667,123 @@ abstract contract InsertionSort{ function insertionSort(uint[] memory a) public pure virtual returns(uint[] memory); } ``` +### 2024.09.30 + +#### 接口(interface) +類似抽象合約,但不實現任何功能。 +* 規則: + 1. 不能包含狀態變量 + 2. 不能包含構造函數 + 3. 不能繼承接口以外的其他合約 + 4. 所有函數都必須是external且不能有函數體 + 5. 繼承 interface 的非抽象合約必須實現 interface 定義的所有功能 + +interface 是智能合約的骨架,定義了合約的功能及如何觸發,若合約實現了某種接口,ex.`ERC20`、`ERC721`,其他`Dapps`和合約就知道該如何與此智能合約交互。 +* 作用: + 1. 標準化交互: + 如果某個智能合約實現了一個通用的接口(如 ERC20 或 ERC721),那麼其他合約或應用程序就能根據這個接口來與其互動,有助於跨平台、跨合約之間的兼容性。 + 2. 定義合約中的功能: + 接口會定義每個函數的名稱和參數類型,以及這些函數如何被調用,這相當於描述了合約的公共 API。 + 3. 定義每個函數哈希(`bytes4`選擇器)、函數簽名(`函數名(每個參數類型)`),以通過對函數的簽名進行哈希後得到獨特的4字節哈希。 + ```Solidity + keccak256("transfer(address,uint256)").slice(0, 4) + ``` + 4. 接口 ID: + 接口 ID 是一個唯一的標識符,用來表示某個合約是否實現了某個接口。 + + +```Solidity +interface IERC721 is IERC165 { + event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); + event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); + event ApprovalForAll(address indexed owner, address indexed operator, bool approved); + + function balanceOf(address owner) external view returns (uint256 balance); + + function ownerOf(uint256 tokenId) external view returns (address owner); + + function safeTransferFrom(address from, address to, uint256 tokenId) external; + + function transferFrom(address from, address to, uint256 tokenId) external; + + function approve(address to, uint256 tokenId) external; + + function getApproved(uint256 tokenId) external view returns (address operator); + + function setApprovalForAll(address operator, bool _approved) external; + + function isApprovedForAll(address owner, address operator) external view returns (bool); + + function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data) external; +} +``` + +#### 什麼時候使用interface? +若知道一個合約實現了`IERC721`,不需要知道他的具體程式實現就可以與之交互。 +ex. +```Solidity +contract interactBAYC { + // 利用BAYC地址创建接口合约变量(ETH主网) + IERC721 BAYC = IERC721(0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D); + + // 通过接口调用BAYC的balanceOf()查询持仓量 + function balanceOfBAYC(address owner) external view returns (uint256 balance){ + return BAYC.balanceOf(owner); + } + + // 通过接口调用BAYC的safeTransferFrom()安全转账 + function safeTransferFromBAYC(address from, address to, uint256 tokenId) external{ + BAYC.safeTransferFrom(from, to, tokenId); + } +} +``` + +#### 異常 +異常命令可以幫助尋找錯誤。 +* `error`:可以在`contract`之外拋出異常,高效且方便的向用戶解釋操作失敗的原因,且在拋出異常時可攜帶參數。 +ex.定義`TransferNotOwner`異常,當用戶不是貨幣`owner`時轉帳會拋出錯誤。 + ```Solidity + error TransferNotOwner(); // 自定义error + + // 攜帶參數的異常,以提示轉帳的帳戶地址 + error TransferNotOwner(address sender); // 自定义的带参数的error + ``` + `error`需搭配`revert`命令使用: + 當用戶不是貨幣`owner`時轉帳會拋出錯誤,否則成功轉帳。 + ```Solidity + function transferOwner1(uint256 tokenId, address newOwner) public { + if(_owners[tokenId] != msg.sender){ + revert TransferNotOwner(); + // revert TransferNotOwner(msg.sender); + } + _owners[tokenId] = newOwner; + } + ``` +* `require`:消耗的gas比`error`高,且會隨著描述異常的字符串長度增加,gas也隨之增加。 + * 使用方法:`require(檢查條件,"異常的描述")`,檢查條件不成立時,拋出異常。 + ```Solidity + function transferOwner2(uint256 tokenId, address newOwner) public { + require(_owners[tokenId] == msg.sender, "Transfer Not Owner"); + _owners[tokenId] = newOwner; + } + ``` +* `assert`:不能解釋拋出異常的原因(相較`require`少了字符串),但仍會在檢查條件不成立時拋出異常。 + ```Solidity + function transferOwner3(uint256 tokenId, address newOwner) public { + assert(_owners[tokenId] == msg.sender); + _owners[tokenId] = newOwner; + } + ``` +#### 驗證 +輸入任意數字、非0地址,呼叫以各種語法寫的異常訊息。 + + + + +* `error`方法`gas`消耗:24457(加入參數後`gas`消耗:24660) +* `require`方法`gas`消耗:24755 +* `assert`方法`gas`消耗:24473 +`error`方法`gas`消耗最少,`require`方法消耗最多,因此在求最小`gas`消耗下可以多加使用`error`。 From 3bfc68c5c7ac6d8a24b2524c9888793854de5e08 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 29 Sep 2024 16:06:57 +0000 Subject: [PATCH 5/8] Update commit status table --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e4035b8..724e767b 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ | JakeDu | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | | Aleng | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | 0xbkbk | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| Yuchen | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| Yuchen | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | cthzhw | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | Ray | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | kongfu | ✅ | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | @@ -1011,6 +1011,7 @@ + <<<<<<< HEAD From 89d66185e872ef60ef4c42b118dd1d19d0718f39 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 29 Sep 2024 16:09:53 +0000 Subject: [PATCH 6/8] Update commit status table --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 724e767b..0d225e84 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ | Eric | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | 0xRory | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | Ramsay | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | -| jaxrunboo | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | +| jaxrunboo | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | danger | ✅ | ✅ | ⭕️ | ✅ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | | Robin | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | DX3906 | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | @@ -1012,6 +1012,7 @@ + <<<<<<< HEAD From bdc1d763173b284cb803610703bf2e5d904080d3 Mon Sep 17 00:00:00 2001 From: Arthur Li <34063465+FFFFourwood@users.noreply.github.com> Date: Mon, 30 Sep 2024 00:21:15 +0800 Subject: [PATCH 7/8] Update FFFFourwood.md --- FFFFourwood.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/FFFFourwood.md b/FFFFourwood.md index 6efb0807..b1dc6a62 100644 --- a/FFFFourwood.md +++ b/FFFFourwood.md @@ -355,6 +355,30 @@ Solidity的合约可以继承多个合约。规则: 另外,接口与合约 ABI(Application Binary Interface)等价,可以相互转换:编译接口可以得到合约的 ABI,利用 `abi-to-sol` 工具,也可以将 ABI json 文件转换为接口 sol 文件。 +### 2024.09.30 + +Error +`error` 是 Solidity 0.8.4 版本新加的内容,方便且高效(省 gas)地向用户解释操作失败的原因,同时还可以在抛出异常的同时携带参数 + +Require +`require` 命令是 Solidity 0.8 版本之前抛出异常的常用方法,目前很多主流合约仍然还在使用它。它很好用,唯一的缺点就是 gas 随着描述异常的字符串长度增加,比 `error` 命令要高。使用方法:`require(检查条件, "异常的描述")`,当检查条件不成立的时候,就会抛出异常。 + +Assert +`assert` 命令一般用于程序员写程序 debug,因为它不能解释抛出异常的原因(比 `require` 少个字符串)。它的用法很简单,`assert(检查条件)`,当检查条件不成立的时候,就会抛出异常。 + + +三种方法的 gas 比较 +我们比较一下三种抛出异常的 gas 消耗,通过 remix 控制台的 Debug 按钮,能查到每次函数调用的 gas 消耗分别如下:(使用 0.8.17 版本编译) + +- `error` 方法 gas 消耗:24457 (加入参数后 gas 消耗:24660) +- `require` 方法 gas 消耗:24755 +- `assert` 方法 gas 消耗:24473 + +我们可以看到,`error` 方法 gas 最少,其次是 `assert`,`require` 方法消耗 gas 最多!因此,`error` 既可以告知用户抛出异常的原因,又能省 gas + +备注: Solidity 0.8.0 之前的版本,`assert` 抛出的是一个 panic exception,会把剩余的 gas 全部消耗,不会返还。更多细节见官方文档。 + + From a7515227de37e273e0cfd97955723797df2064e1 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 29 Sep 2024 16:21:30 +0000 Subject: [PATCH 8/8] Update commit status table --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d225e84..6cd18eee 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ | danger | ✅ | ✅ | ⭕️ | ✅ | ✅ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | | | Robin | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | | DX3906 | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | -| FFFFourwood | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | +| FFFFourwood | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | YSKMQAQ | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | CHENkai8385 | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | | | | Ariel | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | | @@ -1013,6 +1013,7 @@ + <<<<<<< HEAD