Skip to main content

Mint Tokens

The xyz token mint command creates new tokens and sends them to a specified address. Only the designated minter can mint tokens.

Usage

xyz token mint <contract> <recipient> <amount> --from <key>

Arguments

ArgumentDescription
contractToken contract address
recipientAddress to receive tokens
amountAmount to mint (in smallest unit)

Flags

FlagDescriptionRequired
--fromSigning key (must be minter)Yes
--dry-runSimulate without broadcastingNo

Examples

Mint to Yourself

xyz token mint xyz1tokencontract... xyz1myaddress... 1000000000 --from mykey

Mint to Another Address

xyz token mint xyz1tokencontract... xyz1recipient... 5000000 --from mykey

Dry Run

xyz token mint xyz1tokencontract... xyz1recipient... 1000000 --from mykey --dry-run
Output:
Dry run mode - transaction not broadcast

Estimated gas: 150,000
Estimated fee: 1,500 uxyz

Mint Details:
  Token: xyz1tokencontract...
  Recipient: xyz1recipient...
  Amount: 1,000,000

Output

Successful mint:
Tokens Minted Successfully!

Token:     xyz1tokencontract...
Recipient: xyz1recipient...
Amount:    1,000,000
TxHash:    ABC123DEF456...
Gas Used:  145678
Block:     12345

Minter Authorization

Only the designated minter can mint tokens:
# Check who can mint
xyz token info xyz1tokencontract...
Output:
Token Information

Name:         My Token
Symbol:       MTK
Decimals:     6
Total Supply: 1,000,000,000,000

Minter:       xyz1minteraddress...
Cap:          Unlimited

Error: Not the Minter

xyz token mint xyz1tokencontract... xyz1recipient... 1000 --from wrongkey
Error: permission denied: only the token minter can mint tokens

Mint Caps

If the token has a cap, minting beyond it fails:
xyz token mint xyz1tokencontract... xyz1recipient... 999999999999999 --from mykey
Error: minting would exceed token cap
Check current supply vs cap:
xyz token info xyz1tokencontract...

Amount Calculation

The amount is in the smallest unit (base amount). For a token with 6 decimals:
Display AmountBase Amount
1 MTK1,000,000
100 MTK100,000,000
0.001 MTK1,000
Example: Mint 1,000 tokens:
xyz token mint xyz1contract... xyz1recipient... 1000000000 --from mykey
#                                              ^ 1000 * 10^6

Batch Minting

For multiple recipients, run multiple commands:
# Mint to multiple addresses
xyz token mint xyz1contract... xyz1addr1... 1000000 --from mykey
xyz token mint xyz1contract... xyz1addr2... 2000000 --from mykey
xyz token mint xyz1contract... xyz1addr3... 3000000 --from mykey
Or script it:
#!/bin/bash
CONTRACT="xyz1tokencontract..."
KEY="mykey"

for addr in xyz1addr1... xyz1addr2... xyz1addr3...; do
  xyz token mint $CONTRACT $addr 1000000 --from $KEY
  sleep 1  # Wait for tx to confirm
done

Under the Hood

xyz token mint executes a MsgExecuteContract:
{
  "contract": "xyz1tokencontract...",
  "msg": {
    "mint": {
      "recipient": "xyz1recipient...",
      "amount": "1000000"
    }
  },
  "funds": []
}

Troubleshooting

You’re not the designated minter. Check:
xyz token info xyz1tokencontract...
# Look at "Minter" field
The token has a maximum supply. Check:
xyz token info xyz1tokencontract...
# Compare Total Supply to Cap
Verify the contract address:
xyz program info xyz1tokencontract...