> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xyzchain.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Mint Tokens

> Create additional token supply

# 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

```bash theme={null}
xyz token mint <contract> <recipient> <amount> --from <key>
```

### Arguments

| Argument    | Description                       |
| ----------- | --------------------------------- |
| `contract`  | Token contract address            |
| `recipient` | Address to receive tokens         |
| `amount`    | Amount to mint (in smallest unit) |

### Flags

| Flag        | Description                   | Required |
| ----------- | ----------------------------- | -------- |
| `--from`    | Signing key (must be minter)  | Yes      |
| `--dry-run` | Simulate without broadcasting | No       |

## Examples

### Mint to Yourself

```bash theme={null}
xyz token mint xyz1tokencontract... xyz1myaddress... 1000000000 --from mykey
```

### Mint to Another Address

```bash theme={null}
xyz token mint xyz1tokencontract... xyz1recipient... 5000000 --from mykey
```

### Dry Run

```bash theme={null}
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:

```bash theme={null}
# 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

```bash theme={null}
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:

```bash theme={null}
xyz token mint xyz1tokencontract... xyz1recipient... 999999999999999 --from mykey
```

```
Error: minting would exceed token cap
```

Check current supply vs cap:

```bash theme={null}
xyz token info xyz1tokencontract...
```

## Amount Calculation

The amount is in the smallest unit (base amount). For a token with 6 decimals:

| Display Amount | Base Amount |
| -------------- | ----------- |
| 1 MTK          | 1,000,000   |
| 100 MTK        | 100,000,000 |
| 0.001 MTK      | 1,000       |

Example: Mint 1,000 tokens:

```bash theme={null}
xyz token mint xyz1contract... xyz1recipient... 1000000000 --from mykey
#                                              ^ 1000 * 10^6
```

## Batch Minting

For multiple recipients, run multiple commands:

```bash theme={null}
# 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:

```bash theme={null}
#!/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`:

```json theme={null}
{
  "contract": "xyz1tokencontract...",
  "msg": {
    "mint": {
      "recipient": "xyz1recipient...",
      "amount": "1000000"
    }
  },
  "funds": []
}
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="Permission denied">
    You're not the designated minter. Check:

    ```bash theme={null}
    xyz token info xyz1tokencontract...
    # Look at "Minter" field
    ```
  </Accordion>

  <Accordion title="Would exceed cap">
    The token has a maximum supply. Check:

    ```bash theme={null}
    xyz token info xyz1tokencontract...
    # Compare Total Supply to Cap
    ```
  </Accordion>

  <Accordion title="Contract not found">
    Verify the contract address:

    ```bash theme={null}
    xyz program info xyz1tokencontract...
    ```
  </Accordion>
</AccordionGroup>
