This tutorial guides you through the process of creating and minting your own coin using the 0x1::managed_coin module on the Initia blockchain. It includes initializing your coin, obtaining metadata, minting coins, and checking the balances.

Step 1: Initialize Your Coin

To initialize your coin, you must call the 0x1::managed_coin::initialize function.

public entry fun initialize(
    account: &signer,
    maximum_supply: Option<u128>,
    name: String,
    symbol: String,
    decimals: u8,
    icon_uri: String,
    project_uri: String,
)
initiad tx move execute 0x1 managed_coin initialize \
    --args '["option<u128>:null", "string:my_coin", "string:MYCOIN", "u8:6", "string:ICON_URI", "string:PROJECT_URI"]' \
    --from [key-name] \
    --gas auto --gas-adjustment 1.5 --gas-prices 0.15uinit \
    --node [rpc-url]:[rpc-port] --chain-id [chain-id]

Step 2: Mint Coin

To mint coins, you will use the 0x1::managed_coin::mint function.

public entry fun mint(
    account: &signer,
    dst_addr: address,
    metadata: Object<Metadata>,
    amount: u64,
)

Before minting, you need to obtain the metadata for your coin, which can be done through the 0x1::coin::metadata view function or by using sha3_256(creator+symbol+0xFE).

Obtaining Metadata

initiad query move view 0x1 coin metadata \
    --args '["address:0x...", "string:MYCOIN"]' \
    --node [rpc-url]:[rpc-port]

# data: '"0x2d81ce0b6708fccc77a537d3d1abac8c9f1f674f4f76390e3e78a89a52d4aacb"'

Minting Coins

initiad tx move execute 0x1 managed_coin mint \
    --args '["address:0x...", "object:0x2d81ce0b6708fccc77a537d3d1abac8c9f1f674f4f76390e3e78a89a52d4aacb", "u64:100000000"]' \
    --from [key-name] \
    --gas auto --gas-adjustment 1.5 --gas-prices 0.15uinit \
    --node [rpc-url]:[rpc-port] --chain-id [chain-id]

After minting, you can check the balances to verify the minting process.