300-move学习奖励
move基础课
Task1
环境安装
- Install 文档已经很齐全了,直接开整
- 01-hello-world 建议查看并熟悉
任务概览
- fork这个仓库 letsmove
复制
mover/001 并重命名为自己github名称,例子:
- 查看task1的任务列表 task1的任务明细 , 交作业的参考文章
- 在项目
letsmove/mover/0x-wen
目录下更新readme.md 在readme.md 中需要填写sui地址,建议使用sui插件钱包中地址,或者okx中sui地址
- 在
letsmove/mover/0x-wen
路径下创建 images文件夹,并上传两个图片,分别为钱包截图和浏览器搜索截图 - 完成后提交本地代码,同步远程最新代码后,全部操作完成后提交PR
操作步骤
完成Sui CLI安装, 根据官方文档安装
1
2
3
4
5安装完成后先生成一个地址
查看,首次则一直回车,如果提示加密方式就选择 0
sui client addresses
创建 {ed25519 | secp256k1 | secp256r1} 不同的加密方式
sui client new-address ed25519完成获取测试网络SUI学习,主要是领取测试网代币
1
2
3
4
5
6
7curl --location --request POST 'https://faucet.testnet.sui.io/gas' \
--header 'Content-Type: application/json' \
--data-raw '{
"FixedAmountRequest": {
"recipient": "替换成本地地址"
}
}'Hello Move 合约必须包含自己github id 输出内容是 github id
1
2
3
4
5
6
7
8
9
10
11
12切换到项目路径:letsmove/mover/0x-wen/code
创建一个项目
sui move new hello
项目结构
tree hello
hello
├── Move.toml
├── sources
│ └── hello.move
└── tests
└── hello_tests.move1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20// 更改hello.move 代码
module hello::hello {
use std::ascii::{String, string};
use sui::object::{Self,UID};
use sui::transfer::transfer;
use sui::tx_context::{TxContext, sender};
public struct Hello has key{
id:UID,
say: String
}
fun init(ctx: &mut TxContext) {
let hello_move = Hello {
id:object::new(ctx),
say: string(b"0x-wen"), // 替换github
};
transfer(hello_move, sender(ctx));
}
}执行部署命令
1
2sui move build
sui client publish # 部署合约提交Hello Move合约发布package id
1
2
3
4
5
6Published Objects:
PackageID: 0xdecabd09762d6a7ed908127b170ce358f80b2d6b1932cbf0845b8731d1802033
Version: 1
Digest: DaUN8sMqky89FvzZvsrJVdVYmGabwkw4KdnkyF1bdXvF
Modules: hello拿着PackageID 去
测试网浏览器【注意切换网络】
搜索一下并截图提交安装好浏览器钱包的截图到 images 目录下
create-dapp
创建一个可以和合约交互的前端应用
通过手脚架生成项目结构
1 | 路径: 0x-wen/code/ |
更改相关配置后部署
1 | 更新默认生成的toml文件 |
替换部署成功后的package-id
1 | // 0x-wen/code/hello_dapp/src/constants.ts |
下载依赖并本地启动
1 | 路径:0x-wen/code/hello_dapp |