Skip to content

Commit

Permalink
task3
Browse files Browse the repository at this point in the history
  • Loading branch information
yueliao11 committed Dec 1, 2024
1 parent 5e500ab commit e5cd0e7
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 0 deletions.
34 changes: 34 additions & 0 deletions mover/yueliao11/code/task3/Move.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 3
manifest_digest = "2B41AE4822173E239CEBD326CC63067D6D4C241D88384DA0A128A80EB8E156C9"
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
dependencies = [
{ id = "Sui", name = "Sui" },
]

[[move.package]]
id = "MoveStdlib"
source = { git = "https://gitee.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/move-stdlib" }

[[move.package]]
id = "Sui"
source = { git = "https://gitee.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/sui-framework" }

dependencies = [
{ id = "MoveStdlib", name = "MoveStdlib" },
]

[move.toolchain-version]
compiler-version = "1.37.1"
edition = "2024.beta"
flavor = "sui"

[env]

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0x3da83250affdd9e22d0a601dac90a9d927149bb94292cf781650ef1fdda6da68"
latest-published-id = "0x3da83250affdd9e22d0a601dac90a9d927149bb94292cf781650ef1fdda6da68"
published-version = "1"
37 changes: 37 additions & 0 deletions mover/yueliao11/code/task3/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "task3"
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
# license = "" # e.g., "MIT", "GPL", "Apache 2.0"
# authors = ["..."] # e.g., ["Joe Smith ([email protected])", "John Snow ([email protected])"]

[dependencies]
Sui = { git = "https://gitee.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" }

# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`.
# Revision can be a branch, a tag, and a commit hash.
# MyRemotePackage = { git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" }

# For local dependencies use `local = path`. Path is relative to the package root
# Local = { local = "../path/to" }

# To resolve a version conflict and force a specific version for dependency
# override use `override = true`
# Override = { local = "../conflicting/version", override = true }

[addresses]
task3 = "0x0"

# Named addresses will be accessible in Move as `@name`. They're also exported:
# for example, `std = "0x1"` is exported by the Standard Library.
# alice = "0xA11CE"

[dev-dependencies]
# The dev-dependencies section allows overriding dependencies for `--test` and
# `--dev` modes. You can introduce test-only dependencies here.
# Local = { local = "../path/to/dev-build" }

[dev-addresses]
# The dev-addresses section allows overwriting named addresses for the `--test`
# and `--dev` modes.
# alice = "0xB0B"

Binary file added mover/yueliao11/code/task3/nft.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions mover/yueliao11/code/task3/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
```
sui move build
sui client publish --gas-budget 100000000
sui client call --function mint \
--module yueliaoNFT \
--package 0x3da83250affdd9e22d0a601dac90a9d927149bb94292cf781650ef1fdda6da68 \
--args "yueliao11" "NFT for yueliao11" 0x7865c7cbd6dc262645ba44713f260e62a66ea99d74746e8823658270cb4a4398 \
--gas-budget 100000000
# mint 一个 NFT 到指定地址
sui client call --function mint \
--module yueliaoNFT \
--package 0x3da83250affdd9e22d0a601dac90a9d927149bb94292cf781650ef1fdda6da68 \
--args "yueliao11" "NFT for yueliao11" "0x7b8e0864967427679b4e129f79dc332a885c6087ec9e187b53451a9006ee15f2" \
--gas-budget 100000000 \
![NFT Mint Screenshot](./nft.jpg)
```
45 changes: 45 additions & 0 deletions mover/yueliao11/code/task3/sources/task3.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module task3::yueliaoNFT {
use sui::tx_context::{Self, TxContext};
use sui::display;
use sui::object::{Self, UID};
use sui::package;
use sui::transfer;
use std::string::{String, utf8};

public struct YUELIAONFT has drop {}

public struct YUELIAO has key, store {
id: UID,
name: String,
description: String,
}

fun init(otw: YUELIAONFT, ctx: &mut TxContext) {
let keys = vector[
utf8(b"name"),
utf8(b"description"),
utf8(b"image_url")
];
let values = vector[
utf8(b"yueliao11"),
utf8(b"NFT for yueliao11"),
utf8(b"https://avatars.githubusercontent.com/u/187120306?u=1902a0c17e07b76b0bb5ff5a93144d78ed5c1ed8&v=4&size=64")
];
let publisher = package::claim(otw, ctx);
let mut display = display::new_with_fields<YUELIAO>(&publisher, keys, values, ctx);
display::update_version(&mut display);

let deployer = tx_context::sender(ctx);
transfer::public_transfer(publisher, deployer);
transfer::public_transfer(display, deployer);
}

public entry fun mint(name: vector<u8>, description: vector<u8>, recipient: address, ctx: &mut TxContext) {
let nft = YUELIAO {
id: object::new(ctx),
name: utf8(name),
description: utf8(description),
};
transfer::public_transfer(nft, recipient);
}
}

0 comments on commit e5cd0e7

Please sign in to comment.