Skip to main content

Create Token

Deploy a new CW20 token on XYZ Chain with the xyz token create command.

Setup

Before creating tokens, ensure the CW20 base contract is deployed.

Deploy CW20 Base Contract

# Run the deployment script
./scripts/deploy-cw20.sh
Downloading CW20 base contract v2.0.0...
Deploying to xyz-testnet-1...

Transaction hash: ABC123...
Code ID: 1

Success! Configure xyz CLI:
  xyz config set cw20-code-id 1

Configure Code ID

xyz config set cw20-code-id 1
Verify:
xyz config get cw20-code-id
# 1

Create a Token

xyz token create \
  --name "My Token" \
  --symbol "MTK" \
  --decimals 6 \
  --initial-supply 1000000000000 \
  --from mykey

Required Flags

FlagDescriptionExample
--nameToken name”My Token”
--symbolTrading symbol (3-12 chars)“MTK”
--decimalsDecimal places (0-18)6
--fromSigning keymykey

Optional Flags

FlagDescriptionDefault
--initial-supplyStarting supply0
--minterMinter addressCreator
--capMaximum supplyUnlimited
--dry-runSimulate onlyfalse

Examples

Basic Token

xyz token create \
  --name "My Token" \
  --symbol "MTK" \
  --decimals 6 \
  --from mykey
Creates a token with no initial supply. You’ll need to mint tokens afterward.

Token with Initial Supply

xyz token create \
  --name "Reward Token" \
  --symbol "RWRD" \
  --decimals 6 \
  --initial-supply 1000000000000 \
  --from mykey
Creates 1,000,000 tokens (with 6 decimals) sent to the creator.

Fixed Supply Token

xyz token create \
  --name "Fixed Token" \
  --symbol "FIX" \
  --decimals 6 \
  --initial-supply 1000000000000 \
  --cap 1000000000000 \
  --from mykey
Creates a token with fixed 1M supply (cap equals initial supply).

Token with Different Minter

xyz token create \
  --name "DAO Token" \
  --symbol "DAO" \
  --decimals 6 \
  --minter xyz1daocontract... \
  --from mykey
Sets a DAO contract as the minter instead of the creator.

Dry Run

Simulate token creation without broadcasting:
xyz token create \
  --name "Test Token" \
  --symbol "TEST" \
  --decimals 6 \
  --from mykey \
  --dry-run
Output:
Dry run mode - transaction not broadcast

Estimated gas: 250,000
Estimated fee: 2,500 uxyz

Token Details:
  Name: Test Token
  Symbol: TEST
  Decimals: 6
  Initial Supply: 0
  Minter: xyz1youraddress...

Output

Successful creation returns:
Token Created Successfully!

Contract: xyz1tokencontract123...
Name:     My Token
Symbol:   MTK
Decimals: 6
TxHash:   ABC123DEF456...
Gas Used: 234567
Block:    12345
Save the contract address! You’ll need it for all future operations (mint, transfer, etc.).

Track Your Token

Add the token to your configuration for balance queries:
# Add to tracked tokens
xyz config set cw20-tokens xyz1tokencontract123...

# Now balance queries include this token
xyz balance --all --key mykey

Decimals Guide

The decimals field determines the smallest unit:
Decimals1 Token =Use Case
01NFT-like, indivisible
61,000,000Standard (like uxyz)
8100,000,000Bitcoin-style
1810^18Ethereum-style
Use 6 decimals to match the native uxyz denomination.

Error Handling

The CLI provides user-friendly error messages:
ErrorMeaningSolution
”cw20-code-id not configured”Missing code IDRun xyz config set cw20-code-id 1
”insufficient funds”Not enough uxyzFund your account
”invalid symbol”Symbol too long/shortUse 3-12 characters

Under the Hood

xyz token create executes a MsgInstantiateContract:
{
  "code_id": 1,
  "label": "MTK Token",
  "msg": {
    "name": "My Token",
    "symbol": "MTK",
    "decimals": 6,
    "initial_balances": [
      {
        "address": "xyz1creator...",
        "amount": "1000000000000"
      }
    ],
    "mint": {
      "minter": "xyz1creator...",
      "cap": null
    }
  },
  "funds": []
}

Next Steps