A Move package that defines a test coin with dynamic metadata management and minting capabilities.
- Dynamic Metadata Management: Update coin name, symbol, decimals, and mintable status
- Minting Control: Pause/resume minting functionality
- Flexible Minting: Mint to self or any recipient address
- Admin Controls: Module address controls all administrative functions
- Error Handling: Comprehensive error codes for different scenarios
- Install Aptos CLI.
- Have a funded testnet account (faucet).
# Configure your Aptos profile
aptos init --network testnet --profile mint_profile --assume-yes
# Check your account address
aptos account list --profile mint_profile | catLocate your account address (e.g., 0xabc...). You will use it as the named address MintToken when publishing.
# From repo root
aptos move publish \
--named-addresses MintToken=$(aptos config show-profiles --json | jq -r '.Result["mint_profile"].account') \
--profile mint_profile \
--assume-yesIf you prefer, replace the --named-addresses value with your hex address directly, e.g. MintToken=0xabc....
Run the init_module entry function once from the module/publisher account.
aptos move run --function-id "MintToken::mint_test_coin::init_module" \
--profile mint_profile --assume-yesaptos move run --function-id "MintToken::mint_test_coin::mint" \
--args u64:1000000 \
--profile mint_profile --assume-yesNote: Minting will fail if the contract is paused (see metadata management below).
RECIPIENT=0x<hex>
aptos move run --function-id "MintToken::mint_test_coin::mint_to" \
--args address:$RECIPIENT u64:1000000 \
--profile mint_profile --assume-yesNote: Only the module address can call this function.
The contract now supports dynamic metadata updates. Only the module address can modify metadata.
# Update name, symbol, decimals, and mintable status
aptos move run --function-id "MintToken::mint_test_coin::update_metadata" \
--args string:"My Token" string:"MTK" u8:8 bool:true \
--profile mint_profile --assume-yes# Pause minting
aptos move run --function-id "MintToken::mint_test_coin::set_mintable" \
--args bool:false \
--profile mint_profile --assume-yes
# Resume minting
aptos move run --function-id "MintToken::mint_test_coin::set_mintable" \
--args bool:true \
--profile mint_profile --assume-yes# Get current metadata (name, symbol, decimals, is_mintable)
aptos move run --function-id "MintToken::mint_test_coin::get_metadata" \
--profile mint_profile --assume-yes
# Check if minting is currently allowed
aptos move run --function-id "MintToken::mint_test_coin::is_mintable" \
--profile mint_profile --assume-yesOWNER=$(aptos config show-profiles --json | jq -r '.Result["mint_profile"].account')
aptos account balance --account $OWNER --profile mint_profile | cat- Permissions: Module address
MintTokencontrolsmint_toand all metadata management functions. Anyone can callminton their own afterinit_moduleis executed by the module address. - Dynamic Metadata: The contract supports updating coin name, symbol, decimals, and mintable status after deployment.
- Minting Control: Minting can be paused/resumed by the module address. All minting functions will fail when paused.
- Default Values: Initial decimals: 6, Symbol: USDC, Name: USDC Coin, Mintable: true.
- Error Codes:
1: Non-module address calling init_module2: Non-module address calling mint_to3: Non-module address calling update_metadata4: Non-module address calling set_mintable5: Attempting to mint when paused