Skip to content

Commit

Permalink
Merge pull request movefuns#122 from bityoume/main
Browse files Browse the repository at this point in the history
add Roadmap2 NFT
  • Loading branch information
uvd authored Dec 27, 2023
2 parents 6389e91 + b92459a commit 60c06b5
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 1 deletion.
6 changes: 6 additions & 0 deletions members/bityoume/journal.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@

[1.4_创建并发布MoveERC20合约](./roadmap/week01/1.4_创建并发布MoveERC20合约.md)

## Roadmap 02

[1.5_NFT发行](https://learnblockchain.cn/article/7172)

[1.6_Move猜数字合约开发](./roadmap/week02/1.6_Move猜数字合约开发.md)

8 changes: 7 additions & 1 deletion members/bityoume/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@

### Roadmap 1

- 项目源码: https://github.com/bityoume/SuiHome/tree/main/rm01/my-first-sui-dapp
- 项目源码: https://github.com/bityoume/Sui-Web3-StarTrek/tree/main/roadmap01/my-first-sui-dapp
- 发布的ERC20
- package1: `0xa230b06d8924c45e0245f744809634da806da44564465d842dc31b3d070355aa` (jscoin)
- package2: `0xc03753a41af246d4f892a39325b1c320cb27bccf34cb90f12767e330d6c9e2ad` (bycoin)


### Roadmap 2
- 项目源码: https://github.com/bityoume/Sui-Web3-StarTrek/tree/main/roadmap02/js_sui_nft
- 发布的NFT
- package: `0x99066b90111de39027907ef20ce934b0119327567890d8c9b99449a1d87b2408`
- url: `https://suiexplorer.com/object/0x99066b90111de39027907ef20ce934b0119327567890d8c9b99449a1d87b2408?deviceId=d91bda4f-734e-4cf7-a391-0ab2fb23f9be&network=testnet`
1 change: 1 addition & 0 deletions members/bityoume/roadmap/week02/1.5_NFT发行.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://learnblockchain.cn/article/7172
71 changes: 71 additions & 0 deletions members/bityoume/roadmap/week02/1.6_Move猜数字合约开发.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Move猜数字合约开发

## 1 合约开发

```rust
module sui_game::guess_number {
use sui::event;
use std::string;
use sui::tx_context::{ TxContext};
use sui::clock::{Self, Clock};

const ERROR_INPUT_NUM :u64 = 1;

struct Result has copy,drop {
msg: string::String
}

entry public fun guess(input_num: u64, clock: &Clock, ctx: &mut TxContext) {

assert!((input_num >= 1 && input_num <=5), ERROR_INPUT_NUM);

let ts_ms = clock::timestamp_ms(clock);
let random = (ts_ms % 5) + 1;

let resp;
if (input_num == random) {
resp = b"You got it :)";
} else {
resp = b"You lose :(";
};

event::emit(Result{msg: string::utf8(resp)});
}
}
```

## 2 部署合约

```bash
$ sui client publish --gas-budget 300000000

......
│ Published Objects: │
│ ┌── │
│ │ PackageID: 0x71976d67669db34c15e613b82840187b398827a9820df5e795bf583d95651b77 │
│ │ Version: 1 │
│ │ Digest: AoNv1mkKiSCZZXMuBjn7J5jV3m6MrhBnha3QnQVzeK4K │
│ │ Modules: guess_number │
│ └── │
......
```

## 3 网页交互

### 3.1 发起猜数字交易

https://suiexplorer.com/object/0x71976d67669db34c15e613b82840187b398827a9820df5e795bf583d95651b77?network=devnet

![image-20231227191654165](assets/image-20231227191654165.png)

### 3.2 猜中数字事件

https://suiexplorer.com/txblock/HPDrZ97rPduCUEjbvHVcDQB9KJSvmYzEgMcqK2qpAoRD?network=devnet

![image-20231227191808793](assets/image-20231227191808793.png)

### 3.3 未猜中数字事件

https://suiexplorer.com/txblock/BuzZx3n1DMgN5iasUG3FcjjUBU8SwXDTSKJzupMMD977?network=devnet

![image-20231227191843000](assets/image-20231227191843000.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 60c06b5

Please sign in to comment.