From 81f8bf2b8c957ed1f14905fbd94084890487d3d9 Mon Sep 17 00:00:00 2001 From: hansen <78713865@qq.com> Date: Mon, 23 Sep 2024 21:28:59 +0800 Subject: [PATCH 01/13] Update Hansen.md --- Hansen.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Hansen.md b/Hansen.md index eed7dcd..6b5a144 100644 --- a/Hansen.md +++ b/Hansen.md @@ -11,6 +11,11 @@ timezone: Asia/Shanghai ## Notes +### 2024.09.23 +听 线上的课程:starknet 工具链与开发环境 +下一步目标,做一个合约,部署在测试链上。 + + ### 2024.09.22 今天 大概看了一下 , cairo 的语法, 安装了 scarb 包管理器 From d76b8e00be6daf2ecb6cde852e839a4cc4065210 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 23 Sep 2024 13:29:16 +0000 Subject: [PATCH 02/13] Update commit status table --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d85ebe1..7051830 100644 --- a/README.md +++ b/README.md @@ -113,11 +113,11 @@ Starknet 残酷共学是由 LXDAO、Starknet Astro、AAStar 联合发起,旨 | Ache | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | | geyu | ⭕️ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | | aliyan404 | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | | | | | | | | | | | | | | | | -| Hansen | ✅ | ✅ | ⭕️ | ✅ | ✅ | | | | | | | | | | | | | | | | | +| Hansen | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | Reign | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | qiaopengjun | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | Ric-Li-C | ✅ | ⭕️ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | -| River | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | +| River | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | | awaqawaqawaq | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | phipupt | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | MartinYeung5 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | @@ -224,6 +224,7 @@ Starknet 残酷共学是由 LXDAO、Starknet Astro、AAStar 联合发起,旨 + From 42ba94bd301987fc7ca4a854365bddd3b69f114d Mon Sep 17 00:00:00 2001 From: geyu Date: Mon, 23 Sep 2024 22:21:26 +0800 Subject: [PATCH 03/13] Step 3 --- geyu.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/geyu.md b/geyu.md index 983432e..63579df 100644 --- a/geyu.md +++ b/geyu.md @@ -26,6 +26,8 @@ fork 了 counter-workshop 通过了counter-workshop Step 3 ### 2024.09.22 通过了counter-workshop Step 4 +### 2024.09.23 +学习 https://docs.starknet.io/ 的文档,目前进度:Deploying a smart contract From 58e84a8eeff48ecdaf024e93bca6e83ef265c506 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 23 Sep 2024 14:22:26 +0000 Subject: [PATCH 04/13] Update commit status table --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7051830..e56b7af 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ Starknet 残酷共学是由 LXDAO、Starknet Astro、AAStar 联合发起,旨 | Name | 9.18 | 9.19 | 9.20 | 9.21 | 9.22 | 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 | | ------------- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | | Ache | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | -| geyu | ⭕️ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | +| geyu | ⭕️ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | aliyan404 | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | | | | | | | | | | | | | | | | | Hansen | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | Reign | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | @@ -225,6 +225,7 @@ Starknet 残酷共学是由 LXDAO、Starknet Astro、AAStar 联合发起,旨 + From 42d9f9eabc27044ecdc8f3856f03b9215d73ba0a Mon Sep 17 00:00:00 2001 From: hansen <78713865@qq.com> Date: Mon, 23 Sep 2024 22:26:26 +0800 Subject: [PATCH 05/13] Update Hansen.md --- Hansen.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Hansen.md b/Hansen.md index 6b5a144..73e11d4 100644 --- a/Hansen.md +++ b/Hansen.md @@ -15,6 +15,13 @@ timezone: Asia/Shanghai 听 线上的课程:starknet 工具链与开发环境 下一步目标,做一个合约,部署在测试链上。 +- https://voyager.online/ stark 的浏览器 +- 部署合约,可以用 starkli 命令行 ,也可以用js-sdk 方式 , 后者更简单 +- address 是 account 的一个属性, 通过address 可以确定你的账号信息。 在部署合约的时候, 只有address 是不够的。 +- 用“人”钱包,部署合约时, 先要 将账号 部署, + + + ### 2024.09.22 今天 大概看了一下 , cairo 的语法, From 8e2df5e449046608a87f3373c1a83bfeaedb39c4 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 23 Sep 2024 14:26:44 +0000 Subject: [PATCH 06/13] Update commit status table --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e56b7af..085abed 100644 --- a/README.md +++ b/README.md @@ -226,6 +226,7 @@ Starknet 残酷共学是由 LXDAO、Starknet Astro、AAStar 联合发起,旨 + From 60124b878413f5cdee2d00fdb8ad0e79c88a8a4f Mon Sep 17 00:00:00 2001 From: Ellenp2p <99389607+Ellenp2p@users.noreply.github.com> Date: Mon, 23 Sep 2024 22:39:22 +0800 Subject: [PATCH 07/13] Update Ellen.md --- Ellen.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Ellen.md b/Ellen.md index 1dfb6db..8caa880 100644 --- a/Ellen.md +++ b/Ellen.md @@ -24,4 +24,12 @@ ### 2024.09.22 - 学习 https://docs.openzeppelin.com/contracts-cairo/0.16.0/erc20 + +### 2024.09.23 +- 听分享部署合约 +- sncast account deploy --fee-token eth --name Test1 +- sncast --account Test1 declare --fee-token eth --contract-name HelloStarknet +- sncast deploy --class-hash 0x1a6835329277e9a402a747e041546d418cee105c2a8de41c6dd4930e80c8681 --fee-token eth + + From a44ab342a32a131e1dbd3f643be0ab3ae44c0671 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 23 Sep 2024 14:39:44 +0000 Subject: [PATCH 08/13] Update commit status table --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 085abed..ece7060 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ Starknet 残酷共学是由 LXDAO、Starknet Astro、AAStar 联合发起,旨 | MartinYeung5 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | dethan3 | ✅ | ⭕️ | ✅ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | Cavn | ✅ | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | -| Ellen | ✅ | ⭕️ | ⭕️ | ✅ | ✅ | | | | | | | | | | | | | | | | | +| Ellen | ✅ | ⭕️ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | @@ -227,6 +227,7 @@ Starknet 残酷共学是由 LXDAO、Starknet Astro、AAStar 联合发起,旨 + From f4a2784f12be5b29f2201b2a4e44fa24394694eb Mon Sep 17 00:00:00 2001 From: coco <1285015889@qq.com> Date: Mon, 23 Sep 2024 23:43:44 +0800 Subject: [PATCH 09/13] update 2024.09.23 note --- River.md | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) diff --git a/River.md b/River.md index 9bfcf7b..a8dca42 100644 --- a/River.md +++ b/River.md @@ -493,6 +493,181 @@ fn plus_one(x: u32) -> u32 { } ~~~ +### 2024.09.23 + +#### 流程控制 + +##### if表达式 + +###### 常规写法 + +~~~rust +fn main() { + let number = 3; + + if number == 12 { + println!("number is 12"); + } else if number == 3 { + println!("number is 3"); + } else if number - 2 == 1 { + println!("number minus 2 is 1"); + } else { + println!("number not found"); + } +} +~~~ + +###### 在let语句中使用if + +~~~rust +fn main() { + let condition = true; + let number = if condition { + 5 + } else { + 6 + }; +} +~~~ + +##### 循环控制 + + 在`Cairo`中有三种Loop循环类型:`loop`、`while`、`for` + +###### `loop` + +* 常规 + + ~~~rust + fn main() { + loop { + println!("again!"); + } + } + ~~~ + +* 带有`break`关键字 + + ~~~rust + fn main() { + let mut i: usize = 0; + loop { + if i > 10 { + break; + } + println!("i = {}", i); + i += 1; + } + } + ~~~ + +* 带有`continue`关键字 + + ~~~rust + fn main() { + let mut i: usize = 0; + loop { + if i > 10 { + break; + } + if i == 5 { + i += 1; + continue; + } + println!("i = {}", i); + i += 1; + } + } + ~~~ + +* 带有返回值 + + ~~~rust + fn main() { + let mut counter = 0; + + let result = loop { + if counter == 10 { + break counter * 2; + } + counter += 1; + }; + println!("The result is {}", result); + } + ~~~ + +###### `while` + +~~~rust +fn main() { + let mut number = 3; + + while number != 0 { + println!("{number}!"); + number -= 1; + }; + + println!("LIFTOFF!!!"); +} +~~~ + +###### `for` + +~~~rust +fn main() { + let a = [10, 20, 30, 40, 50].span(); + + for element in a { + println!("the value is: {element}"); + } + + for number in 1..4_u8 { + println!("{number}!"); + }; +} +~~~ + +###### Loops与递归 + +Loops和递归是两种重复执行代码的方式。 + +* `loop`关键字用来创建一个无限循环,同时使用`break`关键字退出循环。 + + ~~~rust + fn main() -> felt252 { + let mut x: felt252 = 0; + loop { + if x == 2 { + break; + } else { + x += 1; + } + }; + x + } + ~~~ + +* 递归通过在函数内部调用自身来实现 + + ~~~rust + fn main() -> felt252 { + recursive_function(0) + } + + fn recursive_function(mut x: felt252) -> felt252 { + if x == 2 { + x + } else { + recursive_function(x + 1) + } + } + ~~~ + +在`Cairo`中,Loops与递归不仅仅在概念上是等价的,同时通过编译在底层表达上也类似。 + + + + From d0d36b209810fbc12b4da831d44ef344bfcc4efa Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 23 Sep 2024 15:44:53 +0000 Subject: [PATCH 10/13] Update commit status table --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ece7060..9c8233c 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ Starknet 残酷共学是由 LXDAO、Starknet Astro、AAStar 联合发起,旨 | Reign | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | qiaopengjun | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | Ric-Li-C | ✅ | ⭕️ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | -| River | ✅ | ✅ | ✅ | ✅ | ✅ | ⭕️ | | | | | | | | | | | | | | | | +| River | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | awaqawaqawaq | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | ✅ | | | | | | | | | | | | | | | | | phipupt | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | MartinYeung5 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | @@ -228,6 +228,7 @@ Starknet 残酷共学是由 LXDAO、Starknet Astro、AAStar 联合发起,旨 + From f4da33aabd5b3f6c3c4a3b2f78fc9a9c337f9245 Mon Sep 17 00:00:00 2001 From: Colder Date: Tue, 24 Sep 2024 07:48:20 +0800 Subject: [PATCH 11/13] Update Reign.md --- Reign.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Reign.md b/Reign.md index fa87717..131878e 100644 --- a/Reign.md +++ b/Reign.md @@ -263,4 +263,39 @@ This chapter provides a guide for compiling, deploying, and interacting with a S - Convert new names to felt252 format before invoking. This chapter outlines the complete workflow for developing and managing Starknet smart contracts, focusing on ensuring compatibility between tools and providing practical commands for contract management. + + +### 2024.09.23 +### Summary of Scarb: The Package Manager + +**Scarb** is the package manager for Cairo and Starknet projects, handling dependencies, compiling projects, and streamlining the development process, similar to Rust's Cargo. Here's an overview of its usage: + +1. **Initialization and Workflow**: + - Set up a project with `scarb new `, which generates a `Scarb.toml` file and a `src/lib.cairo` file. + - Add dependencies directly in the `Scarb.toml` file or via the `scarb add` command. + - Compile projects into Sierra code using `scarb build`, producing an intermediate output for deployment to Starknet. + +2. **Project Structure**: + - A typical Cairo package includes a `Scarb.toml` file and a `src` directory containing `.cairo` files (e.g., `lib.cairo`). + - External libraries can be added via the `[dependencies]` section of `Scarb.toml`, specifying either registry or Git sources. + +3. **Components**: + - Starting with version 2.3.0, Scarb supports **Components**—modular add-ons that encapsulate reusable logic, storage, and events for smart contracts, allowing for easy extension of contract functionality. + +4. **Example**: + - A simple Cairo contract can be modularized using components, such as separating ownership logic into an `ownable_component` module and integrating it with the main contract. + +5. **Commands Cheat Sheet**: + - `scarb new `: Initialize a new project. + - `scarb build`: Compile the project into Sierra code. + - `scarb add --git `: Add a Git-hosted dependency. + - `scarb clean`: Remove build artifacts. + +6. **Version Changes**: + - Version 2.3.0 introduced JSON outputs for Sierra and CASM code and support for components. + + + + + From a23fefc792467e383827c6ac51d1c19e6a94d36e Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 23 Sep 2024 23:48:35 +0000 Subject: [PATCH 12/13] Update commit status table --- README.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9c8233c..d87f5dd 100644 --- a/README.md +++ b/README.md @@ -111,19 +111,19 @@ Starknet 残酷共学是由 LXDAO、Starknet Astro、AAStar 联合发起,旨 | Name | 9.18 | 9.19 | 9.20 | 9.21 | 9.22 | 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 | | ------------- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | | Ache | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | | -| geyu | ⭕️ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | -| aliyan404 | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | | | | | | | | | | | | | | | | -| Hansen | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | -| Reign | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | -| qiaopengjun | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | -| Ric-Li-C | ✅ | ⭕️ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | +| geyu | ⭕️ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | +| aliyan404 | ✅ | ✅ | ✅ | ⭕️ | ✅ | ✅ | | | | | | | | | | | | | | | | +| Hansen | ✅ | ✅ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | +| Reign | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | +| qiaopengjun | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | +| Ric-Li-C | ✅ | ⭕️ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | River | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | -| awaqawaqawaq | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | ✅ | | | | | | | | | | | | | | | | -| phipupt | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | -| MartinYeung5 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | +| awaqawaqawaq | ✅ | ✅ | ✅ | ⭕️ | ⭕️ | ✅ | | | | | | | | | | | | | | | | +| phipupt | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | +| MartinYeung5 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | | dethan3 | ✅ | ⭕️ | ✅ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | | Cavn | ✅ | ✅ | ⭕️ | ⭕️ | ❌ | | | | | | | | | | | | | | | | | -| Ellen | ✅ | ⭕️ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | +| Ellen | ✅ | ⭕️ | ⭕️ | ✅ | ✅ | ✅ | | | | | | | | | | | | | | | | @@ -229,6 +229,7 @@ Starknet 残酷共学是由 LXDAO、Starknet Astro、AAStar 联合发起,旨 + From fb7181743779c06c87f7807664a83823a834e8f6 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 24 Sep 2024 00:57:45 +0000 Subject: [PATCH 13/13] Update commit status table --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d87f5dd..3227a72 100644 --- a/README.md +++ b/README.md @@ -230,6 +230,7 @@ Starknet 残酷共学是由 LXDAO、Starknet Astro、AAStar 联合发起,旨 +