diff --git a/mover/SherVite/code/Task5_Swap/Swap/.gitignore b/mover/SherVite/code/Task5_Swap/Swap/.gitignore new file mode 100644 index 000000000..a007feab0 --- /dev/null +++ b/mover/SherVite/code/Task5_Swap/Swap/.gitignore @@ -0,0 +1 @@ +build/* diff --git a/mover/SherVite/code/Task5_Swap/Swap/Move.lock b/mover/SherVite/code/Task5_Swap/Swap/Move.lock new file mode 100644 index 000000000..16008ec2d --- /dev/null +++ b/mover/SherVite/code/Task5_Swap/Swap/Move.lock @@ -0,0 +1,68 @@ +# @generated by Move, please check-in and do not edit manually. + +[move] +version = 3 +manifest_digest = "D956F2EFC491ADC191658BFBA6A01D96AEE8FEF688024CBC7967616E2DAA5942" +deps_digest = "397E6A9F7A624706DBDFEE056CE88391A15876868FD18A88504DA74EB458D697" +dependencies = [ + { id = "Bridge", name = "Bridge" }, + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, + { id = "SuiSystem", name = "SuiSystem" }, + { id = "task2_coin", name = "task2_coin" }, +] + +[[move.package]] +id = "Bridge" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/bridge" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, + { id = "SuiSystem", name = "SuiSystem" }, +] + +[[move.package]] +id = "MoveStdlib" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/move-stdlib" } + +[[move.package]] +id = "Sui" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/sui-framework" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, +] + +[[move.package]] +id = "SuiSystem" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/sui-system" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, +] + +[[move.package]] +id = "task2_coin" +source = { local = "..\\..\\task2_coin" } + +dependencies = [ + { id = "Bridge", name = "Bridge" }, + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, + { id = "SuiSystem", name = "SuiSystem" }, +] + +[move.toolchain-version] +compiler-version = "1.47.0" +edition = "2024.beta" +flavor = "sui" + +[env] + +[env.mainnet] +chain-id = "35834a8a" +original-published-id = "0xefef43e6ce1e42e17c9f4d3a209217e6aa25ffa040edd4b1cc5425dc2e1c348c" +latest-published-id = "0xefef43e6ce1e42e17c9f4d3a209217e6aa25ffa040edd4b1cc5425dc2e1c348c" +published-version = "1" diff --git a/mover/SherVite/code/Task5_Swap/Swap/Move.toml b/mover/SherVite/code/Task5_Swap/Swap/Move.toml new file mode 100644 index 000000000..ecad5a2f2 --- /dev/null +++ b/mover/SherVite/code/Task5_Swap/Swap/Move.toml @@ -0,0 +1,37 @@ +[package] +name = "Swap" +edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move +# license = "" # e.g., "MIT", "GPL", "Apache 2.0" +# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] + +[dependencies] +task2_coin = { local = "../../task2_coin" } +# 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] +swap = "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" + diff --git a/mover/SherVite/code/Task5_Swap/Swap/sources/swap.move b/mover/SherVite/code/Task5_Swap/Swap/sources/swap.move new file mode 100644 index 000000000..d88af43dc --- /dev/null +++ b/mover/SherVite/code/Task5_Swap/Swap/sources/swap.move @@ -0,0 +1,121 @@ +module swap::swap{ + use sui::balance; + use sui::balance::Balance; + use sui::coin; + use sui::coin::Coin; + use sui::transfer::{transfer, share_object, public_transfer}; + use task2_coin::oiia_faucet::{OIIA_FAUCET}; + use task2_coin::oiia::{OIIA}; + + const CoinNotEnough: u64 = 100; + const FauceOIIANotEnough: u64 = 101; + const WalletNotEnough: u64 = 102; + + public struct AdminCap has key { + id: UID + } + + // Swap pool + public struct Swap has key { + id: UID, + coin: Balance, + faucet_coin: Balance + } + + fun init(ctx: &mut TxContext) { + let adminCap = AdminCap { id: object::new(ctx) }; + let swap = Swap { + id: object::new(ctx), + coin: balance::zero(), + faucet_coin: balance::zero() + }; + transfer(adminCap, ctx.sender()); + // share the swap pool + share_object(swap); + } + + + public entry fun coin_to_faucet( + swap: &mut Swap, + in_coin: &mut Coin, + in_amount: u64, + ctx: &mut TxContext + ) { + // wallet has enough coin + assert!(in_coin.value() >= in_amount, WalletNotEnough); + let coin_old_value = swap.coin.value(); + let fauct_coin_old_value = swap.faucet_coin.value(); + let const_value = coin_old_value * fauct_coin_old_value; + let coin_new_value = coin_old_value + in_amount; + // make sure the x total value * y total value = k + let fauct_coin_new_value = const_value / coin_new_value; + // the amount of faucet_coin to give + let out_amount = fauct_coin_old_value - fauct_coin_new_value; + // swap pool has enough faucet_coin + assert!(swap.faucet_coin.value() >= out_amount, FauceOIIANotEnough); + // swap pool add coin + swap.coin.join(coin::into_balance(in_coin.split(in_amount, ctx))); + // swap pool give faucet_coin + let takeCoin = coin::from_balance(swap.faucet_coin.split(out_amount), ctx); + // transfer to user + public_transfer(takeCoin, ctx.sender()); + } + + public entry fun faucet_to_coin( + swap: &mut Swap, + in_coin: &mut Coin, + in_amount: u64, + ctx: &mut TxContext + ) { + // wallet has enough faucet_coin + assert!(in_coin.value() >= in_amount, WalletNotEnough); + let coin_old_value = swap.coin.value(); + let fauct_coin_old_value = swap.faucet_coin.value(); + let const_value = coin_old_value * fauct_coin_old_value; + let fauct_coin_new_value = fauct_coin_old_value + in_amount; + let coin_new_value = const_value / fauct_coin_new_value; + let out_amount = coin_old_value - coin_new_value; + assert!(swap.coin.value() >= out_amount, CoinNotEnough); + // swap pool add faucet_coin + swap.faucet_coin.join(coin::into_balance(in_coin.split(in_amount, ctx))); + // swap pool give coin + let out_coin = coin::from_balance(swap.coin.split(out_amount), ctx); + // transfer to user + public_transfer(out_coin, ctx.sender()); + } + + public entry fun deposit( + _: &AdminCap, + swap: &mut Swap, + coin: &mut Coin, + coin_amt: u64, + faucet_coin: &mut Coin, + faucet_coin_amount: u64, + ctx: &mut TxContext + ) { + if (coin_amt > 0) { + swap.coin.join(coin::into_balance(coin.split(coin_amt, ctx))); + }; + if (faucet_coin_amount > 0) { + swap.faucet_coin.join(coin::into_balance(faucet_coin.split(faucet_coin_amount, ctx))); + }; + } + + + public entry fun withdraw( + _: &AdminCap, + swap: &mut Swap, + coin_amount: u64, + faucet_coin_amount: u64, + ctx: &mut TxContext + ) { + if (coin_amount > 0 && swap.coin.value() > 0) { + let take_coin = coin::from_balance(swap.coin.split(coin_amount), ctx); + public_transfer(take_coin, ctx.sender()); + }; + if (faucet_coin_amount > 0 && swap.faucet_coin.value() > 0) { + let take_faucet_coin = coin::from_balance(swap.faucet_coin.split(faucet_coin_amount), ctx); + public_transfer(take_faucet_coin, ctx.sender()); + }; + } +} \ No newline at end of file diff --git a/mover/SherVite/code/Task5_Swap/Swap/tests/swap_tests.move b/mover/SherVite/code/Task5_Swap/Swap/tests/swap_tests.move new file mode 100644 index 000000000..81f52899c --- /dev/null +++ b/mover/SherVite/code/Task5_Swap/Swap/tests/swap_tests.move @@ -0,0 +1,18 @@ +/* +#[test_only] +module swap::swap_tests; +// uncomment this line to import the module +// use swap::swap; + +const ENotImplemented: u64 = 0; + +#[test] +fun test_swap() { + // pass +} + +#[test, expected_failure(abort_code = ::swap::swap_tests::ENotImplemented)] +fun test_swap_fail() { + abort ENotImplemented +} +*/ diff --git a/mover/SherVite/code/Task7/ctf7/.gitignore b/mover/SherVite/code/Task7/ctf7/.gitignore new file mode 100644 index 000000000..a007feab0 --- /dev/null +++ b/mover/SherVite/code/Task7/ctf7/.gitignore @@ -0,0 +1 @@ +build/* diff --git a/mover/SherVite/code/Task7/ctf7/Move.lock b/mover/SherVite/code/Task7/ctf7/Move.lock new file mode 100644 index 000000000..7acdf9cdb --- /dev/null +++ b/mover/SherVite/code/Task7/ctf7/Move.lock @@ -0,0 +1,56 @@ +# @generated by Move, please check-in and do not edit manually. + +[move] +version = 3 +manifest_digest = "F8C66222E31F54B6E25DBBB21D9CBD788D3480EE2F04A26C1EC88EB5C622BC87" +deps_digest = "F9B494B64F0615AED0E98FC12A85B85ECD2BC5185C22D30E7F67786BB52E507C" +dependencies = [ + { id = "Bridge", name = "Bridge" }, + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, + { id = "SuiSystem", name = "SuiSystem" }, +] + +[[move.package]] +id = "Bridge" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/bridge" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, + { id = "SuiSystem", name = "SuiSystem" }, +] + +[[move.package]] +id = "MoveStdlib" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/move-stdlib" } + +[[move.package]] +id = "Sui" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/sui-framework" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, +] + +[[move.package]] +id = "SuiSystem" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/sui-system" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, +] + +[move.toolchain-version] +compiler-version = "1.47.0" +edition = "2024.beta" +flavor = "sui" + +[env] + +[env.mainnet] +chain-id = "35834a8a" +original-published-id = "0x9f16384006b3dc0ff2927d7eae90186469cb6475d67862822c5f6cedd38c93f6" +latest-published-id = "0x9f16384006b3dc0ff2927d7eae90186469cb6475d67862822c5f6cedd38c93f6" +published-version = "1" diff --git a/mover/SherVite/code/Task7/ctf7/Move.toml b/mover/SherVite/code/Task7/ctf7/Move.toml new file mode 100644 index 000000000..5333219a9 --- /dev/null +++ b/mover/SherVite/code/Task7/ctf7/Move.toml @@ -0,0 +1,36 @@ +[package] +name = "ctf7" +edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move +# license = "" # e.g., "MIT", "GPL", "Apache 2.0" +# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] + +[dependencies] + +# 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] +ctf7 = "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" + diff --git a/mover/SherVite/code/Task7/ctf7/sources/ctf7.move b/mover/SherVite/code/Task7/ctf7/sources/ctf7.move new file mode 100644 index 000000000..621fcfb9b --- /dev/null +++ b/mover/SherVite/code/Task7/ctf7/sources/ctf7.move @@ -0,0 +1,57 @@ +/* +/// Module: ctf7 +module ctf7::ctf7; +*/ + +// For Move coding conventions, see +// https://docs.sui.io/concepts/sui-move-concepts/conventions + + +module ctf7::ctf_checkin; + + use sui::bcs; + use std::hash; + use sui::event; + + #[test_only] + use std::debug::print; + + + public struct CalculateFlagEvent has drop, copy { + github_id: vector, + flag_str: vector, + flag: vector + } + + entry fun calculate_flag( + github_id: vector, + flag_str: vector, + _ctx: &mut TxContext + ): vector { + + let mut bcs_flag = bcs::to_bytes(&flag_str); + vector::append(&mut bcs_flag, github_id); + + let flag = hash::sha3_256(bcs_flag); + + event::emit(CalculateFlagEvent { + github_id, + flag_str, + flag + }); + + flag + } + + #[test] + fun test_calculate_flag() { + let github_id = b"SherVite"; + let flag_str = b"LETSSUIMOVECTF"; + + let mut bcs_flag = bcs::to_bytes(&flag_str); + vector::append(&mut bcs_flag, github_id); + + let flag = hash::sha3_256(bcs_flag); + print(&flag); + // print(&(flag.to_string())); + } \ No newline at end of file diff --git a/mover/SherVite/code/Task7/ctf7/tests/ctf7_tests.move b/mover/SherVite/code/Task7/ctf7/tests/ctf7_tests.move new file mode 100644 index 000000000..702038ff3 --- /dev/null +++ b/mover/SherVite/code/Task7/ctf7/tests/ctf7_tests.move @@ -0,0 +1,18 @@ +/* +#[test_only] +module ctf7::ctf7_tests; +// uncomment this line to import the module +// use ctf7::ctf7; + +const ENotImplemented: u64 = 0; + +#[test] +fun test_ctf7() { + // pass +} + +#[test, expected_failure(abort_code = ::ctf7::ctf7_tests::ENotImplemented)] +fun test_ctf7_fail() { + abort ENotImplemented +} +*/ diff --git a/mover/SherVite/code/Task8/Ctf8/.gitignore b/mover/SherVite/code/Task8/Ctf8/.gitignore new file mode 100644 index 000000000..a007feab0 --- /dev/null +++ b/mover/SherVite/code/Task8/Ctf8/.gitignore @@ -0,0 +1 @@ +build/* diff --git a/mover/SherVite/code/Task8/Ctf8/Move.lock b/mover/SherVite/code/Task8/Ctf8/Move.lock new file mode 100644 index 000000000..f0801f0f0 --- /dev/null +++ b/mover/SherVite/code/Task8/Ctf8/Move.lock @@ -0,0 +1,56 @@ +# @generated by Move, please check-in and do not edit manually. + +[move] +version = 3 +manifest_digest = "75FDA38AFD729E3538CA76E6E35F9F922D15D3AE36EC6FC748026084B8E839EA" +deps_digest = "F9B494B64F0615AED0E98FC12A85B85ECD2BC5185C22D30E7F67786BB52E507C" +dependencies = [ + { id = "Bridge", name = "Bridge" }, + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, + { id = "SuiSystem", name = "SuiSystem" }, +] + +[[move.package]] +id = "Bridge" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/bridge" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, + { id = "SuiSystem", name = "SuiSystem" }, +] + +[[move.package]] +id = "MoveStdlib" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/move-stdlib" } + +[[move.package]] +id = "Sui" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/sui-framework" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, +] + +[[move.package]] +id = "SuiSystem" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/sui-system" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, +] + +[move.toolchain-version] +compiler-version = "1.47.0" +edition = "2024.beta" +flavor = "sui" + +[env] + +[env.mainnet] +chain-id = "35834a8a" +original-published-id = "0xf2ce1b2ae9194ab8018279197f57ad4a4a3e832eebeeed2d0470615b1394be2f" +latest-published-id = "0xf2ce1b2ae9194ab8018279197f57ad4a4a3e832eebeeed2d0470615b1394be2f" +published-version = "1" diff --git a/mover/SherVite/code/Task8/Ctf8/Move.toml b/mover/SherVite/code/Task8/Ctf8/Move.toml new file mode 100644 index 000000000..f48897c2a --- /dev/null +++ b/mover/SherVite/code/Task8/Ctf8/Move.toml @@ -0,0 +1,36 @@ +[package] +name = "Ctf8" +edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move +# license = "" # e.g., "MIT", "GPL", "Apache 2.0" +# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] + +[dependencies] + +# 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] +ctf8 = "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" + diff --git a/mover/SherVite/code/Task8/Ctf8/sources/Proof.py b/mover/SherVite/code/Task8/Ctf8/sources/Proof.py new file mode 100644 index 000000000..646496efa --- /dev/null +++ b/mover/SherVite/code/Task8/Ctf8/sources/Proof.py @@ -0,0 +1,26 @@ +import hashlib + +# 发送者地址(替换为您实际的地址) +sender_address = bytes.fromhex("748ab0101702695a5624680710b9a470f89c6df5cbc4889a6159bb7d5c54f57f") + +# Challenge 对象的 BCS 字节 +challenge_bytes = bytes([ + 232, 228, 170, 217, 183, 101, 218, 47, 144, 238, 129, 196, 158, 69, 80, 234, + 62, 80, 69, 197, 51, 137, 253, 137, 184, 236, 78, 35, 171, 237, 221, 119, + 11, 76, 101, 116, 115, 77, 111, 118, 101, 67, 84, 70, 3, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 +]) + +# 难度值 +difficulty = 3 + +# 搜索 proof +nonce = 0 +while True: + proof = nonce.to_bytes(8, 'little') # 使用 8 字节的 proof + full_proof = proof + sender_address + challenge_bytes + hash_value = hashlib.sha3_256(full_proof).digest() + if sum(hash_value[:difficulty]) == 0: + print(f"找到 proof: {proof.hex()}") + break + nonce += 1 \ No newline at end of file diff --git a/mover/SherVite/code/Task8/Ctf8/sources/Proof2.py b/mover/SherVite/code/Task8/Ctf8/sources/Proof2.py new file mode 100644 index 000000000..d93c93b8d --- /dev/null +++ b/mover/SherVite/code/Task8/Ctf8/sources/Proof2.py @@ -0,0 +1,69 @@ +import hashlib +import base64 +from typing import List + +# 模拟 Challenge 对象的初始状态(需根据实际合约构造) +def serialize_challenge() -> bytes: + # BCS 序列化逻辑:str="LetsMoveCTF", difficulty=3, ture_num=0 + # 简化示例,实际需使用 BCS 库 + str_bytes = b"LetsMoveCTF" + difficulty_bytes = 3.to_bytes(8, 'little') # u64 类型,8字节 + ture_num_bytes = 0.to_bytes(8, 'little') # u64 类型,8字节 + + # 拼接各字段(实际 BCS 格式可能更复杂) + return str_bytes + difficulty_bytes + ture_num_bytes + +# 计算符合条件的 proof +def find_valid_proof(sender_address: bytes) -> List[int]: + challenge_bytes = serialize_challenge() + proof = [] # 初始为空字节数组 + + while True: + # 构造 full_proof = proof + sender_bytes + challenge_bytes + full_proof = bytes(proof) + sender_address + challenge_bytes + + # 计算 SHA3-256 哈希 + hash_result = hashlib.sha3_256(full_proof).digest() + + # 检查前3字节之和是否为0 + if sum(hash_result[:3]) == 0: + return proof + + # 尝试下一个可能的 proof(简单递增,实际可优化) + proof = increment_proof(proof) + +# 递增 proof 数组(类似计数器) +def increment_proof(proof: List[int]) -> List[int]: + if not proof: # 空数组 -> [0] + return [0] + + proof = proof.copy() + i = len(proof) - 1 + + while i >= 0: + if proof[i] < 255: + proof[i] += 1 + return proof + else: + proof[i] = 0 + i -= 1 + + # 所有位都是255 -> 增加一位 + return [0] + proof + +# 主函数:生成 proof 并转为十六进制 +def main(): + # 替换为你的 Sui 地址字节(需从地址字符串转换) + sender_address = bytes.fromhex("你的Sui地址去掉0x前缀") + + # 计算符合条件的 proof + proof = find_valid_proof(sender_address) + + # 转为十六进制字符串(如 "0x1a2b3c") + proof_hex = "0x" + bytes(proof).hex() + print(f"找到有效 proof: {proof_hex}") + + return proof_hex + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/mover/SherVite/code/Task8/Ctf8/sources/ctf8.move b/mover/SherVite/code/Task8/Ctf8/sources/ctf8.move new file mode 100644 index 000000000..edc645be7 --- /dev/null +++ b/mover/SherVite/code/Task8/Ctf8/sources/ctf8.move @@ -0,0 +1,106 @@ +/* +/// Module: ctf8 +module ctf8::ctf8; +*/ + +// For Move coding conventions, see +// https://docs.sui.io/concepts/sui-move-concepts/conventions + + +module ctf8::lets_move { + use std::ascii::{String, string}; + use std::hash; + use sui::event; + use sui::bcs; + use sui::random; + use sui::random::Random; + use sui::transfer::share_object; + + #[test_only] + use std::debug::print; + + const EPROOF: u64 = 0; + +//定义了一个公共结构体 Flag,用于事件记录,sender记录触发事件用户地址;flag记录成功true;成功次数, + public struct Flag has copy, drop { + sender: address, + flag: bool, + ture_num: u64, + github_id: String + } + + public struct Challenge has key { + id: UID, + str: String, + difficulity: u64, //difficulity: u64:难度级别,决定哈希前缀检查的字节数 + ture_num: u64 + } +//定义了初始化函数,初始字符串为 "LetsMoveCTF",设置难度为 3 + fun init(ctx: &mut TxContext) { + let flag_str = Challenge { + id: object::new(ctx), + str: string(b"LetsMoveCTF"), + difficulity: 3, //即哈希前 3 个字节需满足条件 + ture_num: 0, + }; + share_object(flag_str); //将 Challenge 对象共享,使所有用户都可以访问和修改它 + } + +//get_flag 函数(核心功能) + entry fun get_flag( + proof: vector, //用户提供的证明字节向量 + github_id: String, + challenge: &mut Challenge, //指向共享的 Challenge 对象的可变引用 + rand: &Random, + ctx: &mut TxContext + ) { +//创建一个空的字节向量 full_proof,用于拼接所有输入 + let mut full_proof: vector = vector::empty(); +//将用户提供的 proof,发送者的地址,challenge 对象序列化都字节化(ctx)并追加到 full_proof + vector::append(&mut full_proof, proof); + vector::append(&mut full_proof, tx_context::sender(ctx).to_bytes()); + vector::append(&mut full_proof, bcs::to_bytes(challenge)); +//对 full_proof 计算 SHA3-256 哈希,结果是一个字节向量 + let hash: vector = hash::sha3_256(full_proof); +//初始化变量:prefix_sum 用于计算哈希前缀字节的和,i 是循环计数器 + let mut prefix_sum: u32 = 0; + let mut i: u64 = 0; +//循环检查哈希的前 difficulity 个字节 + while (i < challenge.difficulity) { + prefix_sum = prefix_sum + (*vector::borrow(&hash, i) as u32); + i = i + 1; //从 hash 中借用第 i 个字节,转为 u32 并累加到 prefix_sum,并计数器递增 + }; + + assert!(prefix_sum == 0, EPROOF); //必须为 0,否则抛出错误 EPROOF,表示 proof 无效 + + challenge.str = getRandomString(rand, ctx); + challenge.ture_num = challenge.ture_num + 1; //成功次数加1,触发一个Flag事件,记录以下事件 + + event::emit(Flag { + sender: tx_context::sender(ctx), + flag: true, + ture_num: challenge.ture_num, + github_id + }); + } + +//定义一个函数,生成随机字符串并返回 + fun getRandomString(rand: &Random, ctx: &mut TxContext): String { + + //随机生成字符串长度,基于 rand 和 ctx,范围在 4 到 30 之间 + + let mut gen = random::new_generator(rand, ctx); + let mut str_len = random::generate_u8_in_range(&mut gen, 4, 30); + //初始化一个空字节向量 rand,用于存储随机字符 + let mut rand: vector = b""; + + //循环生成随机字符,达到指定长度,范围在 34 到 126,将随机字节追加到 rand,rand 转换为 String 类型并返回 + while (str_len != 0) { + let rand_num = random::generate_u8_in_range(&mut gen, 34, 126); + vector::push_back(&mut rand, rand_num); + str_len = str_len - 1; //长度计数器减 1 + }; + + string(rand) + } +} diff --git a/mover/SherVite/code/Task8/Ctf8/tests/ctf8_tests.move b/mover/SherVite/code/Task8/Ctf8/tests/ctf8_tests.move new file mode 100644 index 000000000..5969de5e5 --- /dev/null +++ b/mover/SherVite/code/Task8/Ctf8/tests/ctf8_tests.move @@ -0,0 +1,18 @@ +/* +#[test_only] +module ctf8::ctf8_tests; +// uncomment this line to import the module +// use ctf8::ctf8; + +const ENotImplemented: u64 = 0; + +#[test] +fun test_ctf8() { + // pass +} + +#[test, expected_failure(abort_code = ::ctf8::ctf8_tests::ENotImplemented)] +fun test_ctf8_fail() { + abort ENotImplemented +} +*/ diff --git a/mover/SherVite/code/readme.md b/mover/SherVite/code/readme.md index e69de29bb..18ba20bc4 100644 --- a/mover/SherVite/code/readme.md +++ b/mover/SherVite/code/readme.md @@ -0,0 +1,57 @@ +编写task4game +/*关联发布的coin包,在toml文件中,与本地coin 文件夹toml中 添加coin package ID;并 local 地址添加本地地址,根据game 文件夹与coin文件夹相对跳转路径,确定/../../task2_coin */ + + +Task2 Coin sources :https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/packages/sui-framework/sources/coin.move + + +sui client call --package 0x1234... --module faucet --function request_faucet --args 0x5678... 1000 + +sui client call --package 0x6aa34e8a862ad6f17b604da93390f9ffe18f4576f020997507613ef2c46d0801 --module oiia --function mint_and_transfer --args 0x3129ea688c4330af54f7a10941972da2fea05ee6f7c44ae75dda305e9fc3da82 1000000000 0x748ab0101702695a5624680710b9a470f89c6df5cbc4889a6159bb7d5c54f57f + + +sui client call --package 0x2 --module coin --function mint_and_transfer --type-args 0xdad9f7e9c2342c75ecdd324e9631da5bd551a709632ba8fa8eed12b11df44dc2::oiia::OIIA --args 0xad73864f7c3780b83b879ad122736728033586edee0bbc53ff5ccfe00a337b9e 1000000000 0x748ab0101702695a5624680710b9a470f89c6df5cbc4889a6159bb7d5c54f57f + +//game play +sui client call --package 0x9813f3e392cf5d4a54ede10c0ef5437dfd5f0d31fcda40fcf4d4c1d9e3a3a1b0 --module game_beta --function Play --args 0xea7e6cb25605973ccef1a23e6c267736385d44a33f02c040bb3c795d999da307 0x8 false 0x995b26bd6c29298c0cc2f46fe9b9fd3ec78209e3469cb309384e854ab69e87d7 100 --gas-budget 1000000 + + + + +//Swap +sui client call --package 0xaec91a2255e515817f10b056ccbab874192e44e2a0021019765302e18098a108 --module CTF_Check_In --function get_flag --args "0xd4e731ef62bf7a989b8ace044007083b32abec02d6474c1605fa2071f29d9810" "SherVite" 0x7cc93f7b71a8a28d0667a6d158b057de4734bd8fbc3511e7eb27d20c4c054d29 0x8 + +sui client call --package 0xaec91a2255e515817f10b056ccbab874192e44e2a0021019765302e18098a108 --module ctf_checkin --function calculate_flag --args "0x5368657256697465" "0x4c4554535355494d4f5645435446" + + +proof:0b4c6574734d6f766543544603000000000000008500000000000000 +CHALLENGE_ID :0xaf5e84181836c1f2203d67679683c97451159d8e22f201ab86af1d78d6cf40e6 + +sui client call \ + --package \ + --module lets_move \ + --function get_flag \ + --args "0x" "你的 GitHub ID" 0x8 + + sui client call \ + --package 0x5b8be518930b1a574bb099c5b1bc033ed530178d5c97a005e336dbc13b6d8232 \ + --module lets_move \ + --function get_flag \ + --args "0x0b4c6574734d6f766543544603000000000000008500000000000000" "SherVite" 0xaf5e84181836c1f2203d67679683c97451159d8e22f201ab86af1d78d6cf40e6 0x8 + +sui client call --package 0xf96e4b20eb2bcaf736a8f249690df86eaf1f7fe3f160d7d2f1cb9a447a89e1cc --module lets_move --function get_flag --args "0xdfefdc0000000000" "SherVite" 0xe8e4aad9b765da2f90ee81c49e4550ea3e5045c53389fd89b8ec4e23abeddd77 0x8 + + +task07 +sui client call --package 0x9f16384006b3dc0ff2927d7eae90186469cb6475d67862822c5f6cedd38c93f6 --module ctf_checkin --function calculate_flag --args b"SherVite" b"LETSSUIMOVECTF" + +task08 SDK get + +sui client execute --package <辅助模块ID> --module helper --function create_random --gas-budget 10000000 + +sui client call \ + --package \ + --module lets_move \ + --function get_flag \ + --args '["0x"]' '"your-github-id"' '0x4e4e44507bf9bc2275949385bb6d23a3a6d50ebf7f36fa1f6724d49508089e09' \ + --gas-budget \ No newline at end of file diff --git a/mover/SherVite/code/taks4/game_beta/.gitignore b/mover/SherVite/code/taks4/game_beta/.gitignore new file mode 100644 index 000000000..a007feab0 --- /dev/null +++ b/mover/SherVite/code/taks4/game_beta/.gitignore @@ -0,0 +1 @@ +build/* diff --git a/mover/SherVite/code/taks4/game_beta/Move.lock b/mover/SherVite/code/taks4/game_beta/Move.lock new file mode 100644 index 000000000..0ef96b643 --- /dev/null +++ b/mover/SherVite/code/taks4/game_beta/Move.lock @@ -0,0 +1,68 @@ +# @generated by Move, please check-in and do not edit manually. + +[move] +version = 3 +manifest_digest = "E89C4707FAA153502857736F2C8AD46A8034A4D93E98F9E043A1E15AD982898B" +deps_digest = "397E6A9F7A624706DBDFEE056CE88391A15876868FD18A88504DA74EB458D697" +dependencies = [ + { id = "Bridge", name = "Bridge" }, + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, + { id = "SuiSystem", name = "SuiSystem" }, + { id = "task2_coin", name = "task2_coin" }, +] + +[[move.package]] +id = "Bridge" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/bridge" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, + { id = "SuiSystem", name = "SuiSystem" }, +] + +[[move.package]] +id = "MoveStdlib" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/move-stdlib" } + +[[move.package]] +id = "Sui" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/sui-framework" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, +] + +[[move.package]] +id = "SuiSystem" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/sui-system" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, +] + +[[move.package]] +id = "task2_coin" +source = { local = "..\\..\\task2_coin" } + +dependencies = [ + { id = "Bridge", name = "Bridge" }, + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, + { id = "SuiSystem", name = "SuiSystem" }, +] + +[move.toolchain-version] +compiler-version = "1.47.0" +edition = "2024.beta" +flavor = "sui" + +[env] + +[env.mainnet] +chain-id = "35834a8a" +original-published-id = "0x9813f3e392cf5d4a54ede10c0ef5437dfd5f0d31fcda40fcf4d4c1d9e3a3a1b0" +latest-published-id = "0x9813f3e392cf5d4a54ede10c0ef5437dfd5f0d31fcda40fcf4d4c1d9e3a3a1b0" +published-version = "1" diff --git a/mover/SherVite/code/taks4/game_beta/Move.toml b/mover/SherVite/code/taks4/game_beta/Move.toml new file mode 100644 index 000000000..607d8a384 --- /dev/null +++ b/mover/SherVite/code/taks4/game_beta/Move.toml @@ -0,0 +1,43 @@ +[package] +name = "game_beta" +edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move +# license = "" # e.g., "MIT", "GPL", "Apache 2.0" +# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] + +[dependencies] + +task2_coin = { local = "../../task2_coin" } +# Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "04f11afaf5e0" } +# 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] +task2_coin = "0x554024c1b70d9cd4b6b03a9ff2a9a6eab8b887dace637ec423001b2383509192" +game_beta = "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" + diff --git a/mover/SherVite/code/taks4/game_beta/sources/game_beta.move b/mover/SherVite/code/taks4/game_beta/sources/game_beta.move new file mode 100644 index 000000000..043f2827b --- /dev/null +++ b/mover/SherVite/code/taks4/game_beta/sources/game_beta.move @@ -0,0 +1,118 @@ +module game_beta::game_beta { + use std::string::String; + use sui::balance; + use sui::balance::Balance; + use sui::coin; + use sui::coin::Coin; + use sui::random; + use sui::random::Random; + // 代币类型(假设已在 Move.toml 中配置) + use task2_coin::oiia_faucet::OIIA_FAUCET; + + // 游戏对象 + public struct FlipGame has key { + id: object::UID, + balance: Balance, + } + + // 管理员 + public struct Admin has key { + id: object::UID, + name: String, + } + + // 初始化函数 + fun init(ctx: &mut TxContext) { + // 初始化一个游戏对象 + let flipgame = FlipGame { + id: object::new(ctx), + balance: balance::zero(), + }; + // 初始化一个管理员对象,管理员名字是 SherVite + let admin = Admin { + id: object::new(ctx), + name: b"SherVite".to_string(), + }; + // 发布者拥有管理员对象 + transfer::transfer(admin, tx_context::sender(ctx)); + // 共享所有权,保证所有人都可以玩 + transfer::share_object(flipgame); + } + + // 存款 + const EUserInsufficientBalance: u64 = 1000; + public entry fun Deposit( + flipgame: &mut FlipGame, + in_coin: &mut Coin, + amount: u64, + ctx: &mut TxContext, + ) { + assert!( + coin::value(in_coin) >= amount, + EUserInsufficientBalance + ); + let split_coin = coin::split(in_coin, amount, ctx); + let split_balance = coin::into_balance(split_coin); + balance::join(&mut flipgame.balance, split_balance); + } + + // 取款,只有管理员操作 + const EGameInsufficientBalance: u64 = 1001; + public entry fun Withdraw( + flipgame: &mut FlipGame, + _: &Admin, + amount: u64, + ctx: &mut TxContext, + ) { + assert!( + balance::value(&flipgame.balance) >= amount, + EGameInsufficientBalance + ); + let out_balance = balance::split(&mut flipgame.balance, amount); + let out_coin = coin::from_balance(out_balance, ctx); + transfer::public_transfer(out_coin, tx_context::sender(ctx)); + } + + // 开始游戏 + entry fun Play( + flipgame: &mut FlipGame, + rnd: &Random, + guess: bool, + in_coin: &mut Coin, + amount: u64, + ctx: &mut TxContext, + ) { + // 检查合约账户余额是否充足 + assert!( + balance::value(&flipgame.balance) >= amount, + EGameInsufficientBalance + ); + // 检查用户的余额是否充足 + assert!( + coin::value(in_coin) >= amount, + EUserInsufficientBalance + ); + // 用户的投入不能超过游戏账户的10% + assert!( + amount * 10 <= balance::value(&flipgame.balance), + EGameInsufficientBalance + ); + + // 生成随机数并判断结果 + let mut gen = random::new_generator(rnd, ctx); + let random_value = random::generate_u8(&mut gen); + let flag = random_value % 2 == 0; // true/false 判断 + + // 如果获胜 + if (flag == guess) { + // 从游戏余额中取出奖励 + let reward_balance = balance::split(&mut flipgame.balance, amount); + let reward_coin = coin::from_balance(reward_balance, ctx); + // 转移奖励给玩家 + transfer::public_transfer(reward_coin, tx_context::sender(ctx)); + } else { + // 玩家失败,代币存入游戏余额 + Deposit(flipgame, in_coin, amount, ctx); + } + } +} \ No newline at end of file diff --git a/mover/SherVite/code/taks4/game_beta/tests/game_beta_tests.move b/mover/SherVite/code/taks4/game_beta/tests/game_beta_tests.move new file mode 100644 index 000000000..557366440 --- /dev/null +++ b/mover/SherVite/code/taks4/game_beta/tests/game_beta_tests.move @@ -0,0 +1,18 @@ +/* +#[test_only] +module game_beta::game_beta_tests; +// uncomment this line to import the module +// use game_beta::game_beta; + +const ENotImplemented: u64 = 0; + +#[test] +fun test_game_beta() { + // pass +} + +#[test, expected_failure(abort_code = ::game_beta::game_beta_tests::ENotImplemented)] +fun test_game_beta_fail() { + abort ENotImplemented +} +*/ diff --git a/mover/SherVite/code/task2_coin/.gitignore b/mover/SherVite/code/task2_coin/.gitignore new file mode 100644 index 000000000..a007feab0 --- /dev/null +++ b/mover/SherVite/code/task2_coin/.gitignore @@ -0,0 +1 @@ +build/* diff --git a/mover/SherVite/code/task2_coin/Move.lock b/mover/SherVite/code/task2_coin/Move.lock new file mode 100644 index 000000000..f6977b7e3 --- /dev/null +++ b/mover/SherVite/code/task2_coin/Move.lock @@ -0,0 +1,56 @@ +# @generated by Move, please check-in and do not edit manually. + +[move] +version = 3 +manifest_digest = "939DC2D576A0662E1EF5A59715C5EBD577FE80552CB60F8E1CF5E480B64B9AA8" +deps_digest = "F9B494B64F0615AED0E98FC12A85B85ECD2BC5185C22D30E7F67786BB52E507C" +dependencies = [ + { id = "Bridge", name = "Bridge" }, + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, + { id = "SuiSystem", name = "SuiSystem" }, +] + +[[move.package]] +id = "Bridge" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/bridge" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, + { id = "SuiSystem", name = "SuiSystem" }, +] + +[[move.package]] +id = "MoveStdlib" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/move-stdlib" } + +[[move.package]] +id = "Sui" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/sui-framework" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, +] + +[[move.package]] +id = "SuiSystem" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "04f11afaf5e0", subdir = "crates/sui-framework/packages/sui-system" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, +] + +[move.toolchain-version] +compiler-version = "1.47.0" +edition = "2024.beta" +flavor = "sui" + +[env] + +[env.mainnet] +chain-id = "35834a8a" +original-published-id = "0x554024c1b70d9cd4b6b03a9ff2a9a6eab8b887dace637ec423001b2383509192" +latest-published-id = "0x554024c1b70d9cd4b6b03a9ff2a9a6eab8b887dace637ec423001b2383509192" +published-version = "1" diff --git a/mover/SherVite/code/task2_coin/Move.toml b/mover/SherVite/code/task2_coin/Move.toml new file mode 100644 index 000000000..af8b64f9a --- /dev/null +++ b/mover/SherVite/code/task2_coin/Move.toml @@ -0,0 +1,36 @@ +[package] +name = "task2_coin" +edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move +# license = "" # e.g., "MIT", "GPL", "Apache 2.0" +# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] + +[dependencies] + +# 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] +task2_coin = "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" + diff --git a/mover/SherVite/code/task2_coin/sources/oiia.move b/mover/SherVite/code/task2_coin/sources/oiia.move new file mode 100644 index 000000000..daf63cde7 --- /dev/null +++ b/mover/SherVite/code/task2_coin/sources/oiia.move @@ -0,0 +1,51 @@ +/* +/// Module: task2_coin +module task2_coin::task2_coin; +*/ + +// For Move coding conventions, see +// https://docs.sui.io/concepts/sui-move-concepts/conventions + + + +module task2_coin::oiia{ + use sui::coin::{Self, create_currency,TreasuryCap}; + use std::option::{some}; + use sui::transfer::{public_transfer, public_freeze_object}; + use sui::url::{Self, Url}; + + public struct OIIA has drop{} + + fun init(oiia: OIIA,ctx: &mut TxContext) { + let url = url::new_unsafe_from_bytes(b"https://raw.githubusercontent.com/SherVite/picture/refs/heads/main/oiia.png"); + let oiia_coin = some(url); + + let (treasury, coin_metadata) = create_currency( + oiia, + 8, + b"OIIA", + b"OIIA", + b"Hello,Mr.Coin!", + oiia_coin, + ctx + ); + public_freeze_object(coin_metadata); + public_transfer(treasury, ctx.sender()); + } + + // 公共入口函数:铸币并转账(用户可调用) + public entry fun mint_and_transfer( + treasury_cap: &mut TreasuryCap, + recipient: address, // 接收者地址 + amount: u64, // 铸币数量 + ctx: &mut TxContext // 交易上下文 + ) { + // 调用框架铸币函数(需确保 OIIA 是合法货币类型) + let coin = coin::mint(treasury_cap, amount, ctx); // 铸币 + public_transfer(coin, recipient); // 转账 + } + +} + + + diff --git a/mover/SherVite/code/task2_coin/sources/oiia_faucet.move b/mover/SherVite/code/task2_coin/sources/oiia_faucet.move new file mode 100644 index 000000000..c74083a7c --- /dev/null +++ b/mover/SherVite/code/task2_coin/sources/oiia_faucet.move @@ -0,0 +1,47 @@ +/* +/// Module: task2_facute_coin +module task2_facute_coin::task2_facute_coin; +*/ + +// For Move coding conventions, see +// https://docs.sui.io/concepts/sui-move-concepts/conventions + + +module task2_coin::oiia_faucet{ + use sui::coin::{Self, create_currency,TreasuryCap}; + use std::option::{some}; + use sui::transfer::{public_transfer, public_freeze_object, public_share_object}; + use sui::url::{Self, Url}; + + public struct OIIA_FAUCET has drop{} + + fun init(oiia: OIIA_FAUCET,ctx: &mut TxContext) { + let url = url::new_unsafe_from_bytes(b"https://raw.githubusercontent.com/SherVite/picture/refs/heads/main/oiia.png"); + let oiia_faucet_coin = some(url); + + let (treasury, coin_metadata) = create_currency( + oiia, + 8, + b"OIIA_FAUCET", + b"OIIA_FAUCET", + b"Hello,Mr.Coin!", + oiia_faucet_coin, + ctx + ); + public_freeze_object(coin_metadata); + public_share_object(treasury); + } + + // 公共入口函数:铸币并转账(用户可调用) + public entry fun mint_and_transfer( + treasury_cap: &mut TreasuryCap, + recipient: address, // 接收者地址 + amount: u64, // 铸币数量 + ctx: &mut TxContext // 交易上下文 + ) { + // 调用框架铸币函数(需确保 OIIA 是合法货币类型) + let coin = coin::mint(treasury_cap, amount, ctx); // 铸币 + public_transfer(coin, recipient); // 转账 + } + +} diff --git a/mover/SherVite/code/task2_coin/tests/task2_coin_tests.move b/mover/SherVite/code/task2_coin/tests/task2_coin_tests.move new file mode 100644 index 000000000..b3f526af6 --- /dev/null +++ b/mover/SherVite/code/task2_coin/tests/task2_coin_tests.move @@ -0,0 +1,18 @@ +/* +#[test_only] +module task2_coin::task2_coin_tests; +// uncomment this line to import the module +// use task2_coin::task2_coin; + +const ENotImplemented: u64 = 0; + +#[test] +fun test_task2_coin() { + // pass +} + +#[test, expected_failure(abort_code = ::task2_coin::task2_coin_tests::ENotImplemented)] +fun test_task2_coin_fail() { + abort ENotImplemented +} +*/ diff --git a/mover/SherVite/images/Task7_CTF_CHECK_IN.png b/mover/SherVite/images/Task7_CTF_CHECK_IN.png new file mode 100644 index 000000000..0dcec737e Binary files /dev/null and b/mover/SherVite/images/Task7_CTF_CHECK_IN.png differ diff --git a/mover/SherVite/images/Task8_CTF_LetsMove.png b/mover/SherVite/images/Task8_CTF_LetsMove.png new file mode 100644 index 000000000..9dc56f610 Binary files /dev/null and b/mover/SherVite/images/Task8_CTF_LetsMove.png differ diff --git a/mover/SherVite/readme.md b/mover/SherVite/readme.md index 8441e46a8..5249947ee 100644 --- a/mover/SherVite/readme.md +++ b/mover/SherVite/readme.md @@ -19,11 +19,10 @@ - [x] package id 在 scan上的查看截图:![Scan截图](./images/Package_2025-03-07_141456.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] My Coin & Faucet Coin package id : 0x554024c1b70d9cd4b6b03a9ff2a9a6eab8b887dace637ec423001b2383509192 //publish in Mainnet +- [x] 转账 `My Coin` hash:8RhgoDWpHcH2JjUAmE5UCzM1cML8xEEMrnYVj6V63kv6 //in Mainnet +- [x] `Faucet Coin` address1 mint hash:6HGQxY6p2Gz5qRhen6FMeGWMcA2ueFDJLx6dX2Es1XFB //publish in mainnet +- [x] `Faucet Coin` address2 mint hash:ELvjqDs56ER6RHPQgEAVgbwaDvRpnEQQreoMjgsu3QLA //publish in mainnet ## 03 move NFT - [x] nft package id :0xb07b67f35bb6b3ea2e07519ea2ed02e6f934903b8f4a1c1233e62d9a0d7bc403 @@ -33,24 +32,25 @@ - [x] 转给指定地址的NFT截图:![Scan截图](./images/Task3_sent_to_other.png) ## 04 Move Game -- [] game package id : -- [] deposit Coin hash: -- [] withdraw `Coin` hash: -- [] play game hash: +- [x] game package id : 0x9813f3e392cf5d4a54ede10c0ef5437dfd5f0d31fcda40fcf4d4c1d9e3a3a1b0 +- [x] deposit Coin hash: 6hrqGGvpwdJhi5WsPH9H91V7knTCLjrgy9kdpQpKxze4 +- [x] withdraw `Coin` hash:FMzWpSsDNXXyiSoVK98WyXd7ZL5w7qhkpEgnBccM6ZUZ +- [x] play game hash:4xwKcGkCSy5xzoJWWMwerG9LoupZrxZfpg81EdUkX9AP ## 05 Move Swap -- [] swap package id : -- [] call swap CoinA-> CoinB hash : -- [] call swap CoinB-> CoinA hash : +- [] swap package id : 0xefef43e6ce1e42e17c9f4d3a209217e6aa25ffa040edd4b1cc5425dc2e1c348c +- [] call swap CoinA-> CoinB hash : F8rp7k7qQ4nhCcC4Ghq34gnonqqyMexxfJ9KpyngwJMw +- [] call swap CoinB-> CoinA hash : 9tBXzNgtUDCY82FJqWW1N3QDPb9jtezYhg4KTxuAoEC6 ## 06 Dapp-kit SDK PTB - [x] save hash :0xd7d90639406652bbb06ed89613636712f8260370b02185b8e346910d0abf7c5c ## 07 Move CTF Check In -- [] CLI call 截图 : ![截图](./images/你的图片地址) -- [] flag hash : +- [x] CLI call 截图 : ![截图](./images/Task7_CTF_CHECK_IN.png) +- [x] flag hash :7T7s5bnh4BJTarhxnzc7NahDAgaut27d3CXVGonKvbLQ ## 08 Move CTF Lets Move -- [] proof : -- [] flag hash : +- [x] proof : 0xdfefdc0000000000 +- [x] flag hash :7kdncpAReGHzt8runNLjmbQaHozviFw2V6MCu8V2hZxo +- [x] 截图 : ![截图](./images/Task8_CTF_LetsMove.png)