diff --git a/mover/Jmagicc/code/task3/sources/jmagiccnft.move b/mover/Jmagicc/code/task3/sources/jmagiccnft.move new file mode 100644 index 000000000..e17105749 --- /dev/null +++ b/mover/Jmagicc/code/task3/sources/jmagiccnft.move @@ -0,0 +1,117 @@ +/// Module: jmagiccnft +module jmagiccnft::jmagiccnft { + use std::debug; + use std::ascii::string; + use sui::url::{Self, Url}; + use std::string; + use sui::object::{Self, ID, UID}; + use sui::event; + use sui::transfer; + use sui::tx_context::{Self, TxContext}; + + + public struct JmagiccNFT has key, store { + id: UID, + name: string::String, + description: string::String, + url: Url, + ex_param: string::String, + } + + // ===== Events ===== + public struct NFTMinted has copy, drop { + object_id: ID, + creator: address, + name: string::String, + } + + // ===== Public view functions ===== + /// Get the NFT's `name` + public fun name(nft: &JmagiccNFT): &string::String { + &nft.name + } + + /// Get the NFT's `description` + public fun description(nft: &JmagiccNFT): &string::String { + &nft.description + } + + /// Get the NFT's `url` + public fun url(nft: &JmagiccNFT): &Url { + &nft.url + } + + // ===== Entrypoints ===== 入口函数 + #[allow(unused_variable)] + public entry fun mint_ntf(ctx: &mut TxContext) + { + debug::print(&string(b"mint ntf")); + let sender = tx_context::sender(ctx); + + let nft = JmagiccNFT { + id: object::new(ctx), + name: string::utf8(b"Jmagicc NTF"), + description: string::utf8(b"This is the description of Jmagicc NTF"), + url: url::new_unsafe_from_bytes(b"https://avatars.githubusercontent.com/u/58356228"), + ex_param: string::utf8(b"ex param"), + }; + + event::emit(NFTMinted { + object_id: object::id(&nft), + creator: sender, + name: nft.name, + }); + + transfer::public_transfer(nft, sender); + + } + + /// Create a new devnet_nft + public entry fun mint_to_sender( + name: vector, + description: vector, + url: vector, + exparam: vector, + ctx: &mut TxContext + ) { + let sender = tx_context::sender(ctx); + let nft = JmagiccNFT { + id: object::new(ctx), + name: string::utf8(name), + description: string::utf8(description), + url: url::new_unsafe_from_bytes(url), + ex_param: string::utf8(exparam), + }; + + event::emit(NFTMinted { + object_id: object::id(&nft), + creator: sender, + name: nft.name, + }); + + transfer::public_transfer(nft, sender); + } + + /// Transfer `nft` to `recipient` + public entry fun transfer( + nft: JmagiccNFT, recipient: address, _: &mut TxContext + ) { + transfer::public_transfer(nft, recipient) + } + + /// Update the `description` of `nft` to `new_description` + public entry fun update_description( + nft: &mut JmagiccNFT, + new_description: vector, + _: &mut TxContext + ) { + nft.description = string::utf8(new_description) + } + + /// Permanently delete `nft` + public entry fun burn(nft: JmagiccNFT, _: &mut TxContext) { + let JmagiccNFT { id, name: _, description: _, url: _, ex_param: _ } = nft; + object::delete(id) + } + +} diff --git a/mover/Jmagicc/images/jmagicc-nft.png b/mover/Jmagicc/images/jmagicc-nft.png new file mode 100644 index 000000000..ee130b646 Binary files /dev/null and b/mover/Jmagicc/images/jmagicc-nft.png differ diff --git a/mover/Jmagicc/readme.md b/mover/Jmagicc/readme.md index 34a857b89..eb1420008 100644 --- a/mover/Jmagicc/readme.md +++ b/mover/Jmagicc/readme.md @@ -26,10 +26,10 @@ - [x] `Faucet Coin` address2 mint hash: 2pnVPpT3mMCrHVgCgpXoP9VSbDeV75VA2yB57Fe3X2ib ## 03 move NFT -- [] nft package id : -- [] nft object id : -- [] 转账 nft hash: -- [] scan上的NFT截图:![Scan截图](./images/你的图片地址) +- [x] nft package id : 0xf2ff2aa355b94f3bb4f0f4781d7c4df708002192d27c7e84ae509fd3a0889de0 +- [x] nft object id : 0x2ac6f5f1f162fd6607bd3880c9438d60c2808074190a73720d7d36bbd86ceee3 +- [x] 转账 nft hash: JEF88V2kwZbEviS9rDvG5LPz7yyaxQ8zSqSmSJqrgTEp +- [x] scan上的NFT截图:![Scan截图](./images/jmagicc-nft.png) ## 04 Move Game - [] game package id :