Skip to content

Commit

Permalink
feat: task2 by share and private object;
Browse files Browse the repository at this point in the history
  • Loading branch information
Jmagicc committed Nov 19, 2024
1 parent aa11c3a commit 2b3cc0e
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 11 deletions.
37 changes: 37 additions & 0 deletions mover/Jmagicc/code/task2/sources/jmagicc_coin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module jmagicc_coin::jmagicc_coin {
use sui::coin::{Self};
use sui::url::{Url,Self};

public struct JMAGICC_COIN has drop {}


fun init(witness: JMAGICC_COIN, ctx: &mut TxContext) {
let (treasury, metadata) = coin::create_currency(
witness,
9, // decimals
b"JMAGICC", // symbol
b"Jmagicc Coin", // name
b"Jmagicc Coin", // description
option::some<Url>(url::new_unsafe_from_bytes(b"https://avatars.githubusercontent.com/u/58356228")), // icon url
ctx
);

// transfer the `TreasuryCap` to the sender, so they can mint and burn
transfer::public_transfer(treasury, tx_context::sender(ctx));

// metadata is typically frozen after creation
transfer::public_freeze_object(metadata);
}


public entry fun mint(
treasury_cap: &mut coin::TreasuryCap<JMAGICC_COIN>, amount: u64, recipient: address, ctx: &mut TxContext
) {
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx);
}


public entry fun burn(treasury_cap: &mut coin::TreasuryCap<JMAGICC_COIN>, target: coin::Coin<JMAGICC_COIN>) {
coin::burn(treasury_cap, target);
}
}
37 changes: 37 additions & 0 deletions mover/Jmagicc/code/task2/sources/jmagicc_faucet_coin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module jmagicc_faucet_coin::jmagicc_faucet_coin {
use sui::coin::{Self};
use sui::url::{Url,Self};

public struct JMAGICC_FAUCET_COIN has drop {}


fun init(witness: JMAGICC_FAUCET_COIN, ctx: &mut TxContext) {
let (treasury_cap, metadata) = coin::create_currency(
witness,
9, // decimals
b"JMAGICC FAUCET", // symbol
b"Jmagicc Faucet Coin", // name
b"Jmagicc Faucet Coin", // description
option::some<Url>(url::new_unsafe_from_bytes(b"https://avatars.githubusercontent.com/u/58356228")), // icon url
ctx
);

transfer::public_freeze_object(metadata);

transfer::public_share_object(treasury_cap)
}


public entry fun mint(
treasury_cap: &mut coin::TreasuryCap<JMAGICC_FAUCET_COIN>, amount: u64, recipient: address, ctx: &mut TxContext
) {
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx);
}


public entry fun burn(treasury_cap: &mut coin::TreasuryCap<JMAGICC_FAUCET_COIN>, target: coin::Coin<JMAGICC_FAUCET_COIN>) {
coin::burn(treasury_cap, target);
}
}


22 changes: 11 additions & 11 deletions mover/Jmagicc/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
## 任务

## 01 hello move
- [] Sui cli version: sui 1.34.0-99ebd8f082f2
- [] Sui钱包截图: ![Sui钱包截图](./images/sui-wallet.png)
- [] package id: 0xc441a563822caa87821d4aeb29948ba735fdc61b7647d313916b6550f89b5a0
- [] package id 在 scan上的查看截图:![Scan截图](./images/package-id.png)

## 02 move coin
- [] My Coin package id :
- [] Faucet package id :
- [] 转账 `My Coin` hash:
- [] `Faucet Coin` address1 mint hash:
- [] `Faucet Coin` address2 mint hash:
- [x] Sui cli version: sui 1.34.0-99ebd8f082f2
- [x] Sui钱包截图: ![Sui钱包截图](./images/sui-wallet.png)
- [x] package id: 0xc441a563822caa87821d4aeb29948ba735fdc61b7647d313916b6550f89b5a0
- [x] package id 在 scan上的查看截图:![Scan截图](./images/package-id.png)

## 02 move coin
- [x] My Coin package id : 0x26c52507cbd06684da94a201bc6228acce8337bb768bd423f7a5d8db5fe28598
- [x] Faucet package id : 0x456356b93dd173dfc641a21db0b53f504baeca59b9679c267692c5b5b3f28369
- [x] 转账 `My Coin` hash: Bc9RUbLhzw31xaE87NmqzpwyXiqx12hanJGgyiPJ1o62
- [x] `Faucet Coin` address1 mint hash: 9GdcMy9xUsVPFZ1TeK6vvQ3DpvUeLTxW1kpH8KoKgPfG
- [x] `Faucet Coin` address2 mint hash: 2pnVPpT3mMCrHVgCgpXoP9VSbDeV75VA2yB57Fe3X2ib

## 03 move NFT
- [] nft package id :
Expand Down

0 comments on commit 2b3cc0e

Please sign in to comment.