module move_coin::ZCDCCOIN {
use sui::coin::{Self, Coin, TreasuryCap};
use sui::url;
public struct ZCDCCOIN has drop {}
/// Module initializer is called once on module publish. A treasury
/// cap is sent to the publisher, who then controls minting and burning
fun init(witness: ZCDCCOIN, ctx: &mut TxContext) {
let (treasury, metadata) = coin::create_currency(
witness,
6,
b"ZCDCCoin",
b"ZCDCCoin",
b"ZCDCCoin is NO.1",
option::some(url::new_unsafe_from_bytes(b"https://aggregator.walrus-testnet.walrus.space/v1/n-e_Ni4LwoBJUwu_Ovccl7Lflh_NmHmvwMpLWLRwCt0")),
ctx
);
transfer::public_freeze_object(metadata);
transfer::public_transfer(treasury, tx_context::sender(ctx));
}
public entry fun mint (
treasury_cap: &mut TreasuryCap<ZCDCCOIN>, amount: u64, recipient: address, ctx: &mut TxContext
) {
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx)
}
public entry fun burn (
treasury_cap: &mut TreasuryCap<ZCDCCOIN>, coin: Coin<ZCDCCOIN>
) {
coin::burn(treasury_cap, coin);
}
}
合约
暴露两个方法
burn
和mint
,这两个方法只能合约发起者进行执行打包发布合约
记录下
TreasuryCap
的objectid 用于mint币mint币
https://suiscan.xyz/testnet/object/0x14789a6e47d1c1a11890e9315daa666079745b9df3f3618ab9f6ec820da9f9d3/contracts
第一个参数写刚刚记录的objectid,第二个写币的数量,第三个写你的钱包地址
查看币