Skip to main content

Token Operations

XYZ Chain supports CW20 tokens - the CosmWasm standard for fungible tokens, similar to ERC-20 on Ethereum or SPL tokens on Solana.

What is CW20?

CW20 is a specification for fungible tokens on CosmWasm chains. It defines:
  • Token metadata (name, symbol, decimals)
  • Balance tracking
  • Transfer operations
  • Minting and burning
  • Allowances (approve/transferFrom)

Token Commands

CommandDescription
xyz token createDeploy a new CW20 token
xyz token mintMint tokens to an address
xyz token transferSend tokens to a recipient
xyz token burnBurn tokens from your balance
xyz token balanceCheck token balance
xyz token infoView token metadata
xyz token listList all tokens you hold

Quick Start

1. Deploy the CW20 Base Contract

First, ensure the CW20 base contract is deployed on the chain:
# Run the deployment script
./scripts/deploy-cw20.sh

# Save the code ID
xyz config set cw20-code-id 1

2. Create a Token

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

3. Check Balance

xyz token balance xyz1tokencontract... --key mykey

4. Transfer Tokens

xyz token transfer xyz1tokencontract... xyz1recipient... 1000000 --from mykey

Token Properties

When creating a token, you define:
PropertyDescriptionExample
nameHuman-readable name”My Token”
symbolTrading symbol”MTK”
decimalsDecimal places6
initial_supplyStarting supply1000000000000
minterWho can mint moreYour address

CW20 vs Native Tokens

FeatureCW20 TokensNative (uxyz)
CreationAnyone can createFixed at genesis
InflationConfigurableZero
QueryContract queryBank module
TransferContract executeBank send
Gas CostHigherLower

Prerequisites

Before creating tokens:
  1. CW20 Code ID - The base contract must be deployed
  2. Sufficient Balance - Gas fees in uxyz
  3. Key Setup - A keypair in your keyring
Check CW20 is configured:
xyz config get cw20-code-id
# Should return a number like: 1
If not configured, see CW20 Setup.

Architecture

┌─────────────────────────────────────────────────────────┐
│                    XYZ Chain                            │
├─────────────────────────────────────────────────────────┤
│                                                         │
│   ┌─────────────────────────────────────────────────┐  │
│   │              x/wasm Module                       │  │
│   │                                                  │  │
│   │   ┌───────────┐  ┌───────────┐  ┌───────────┐   │  │
│   │   │  CW20     │  │  CW20     │  │  CW20     │   │  │
│   │   │  Token A  │  │  Token B  │  │  Token C  │   │  │
│   │   │ (MTK)     │  │ (USDC)    │  │ (TEST)    │   │  │
│   │   └───────────┘  └───────────┘  └───────────┘   │  │
│   │        │              │              │          │  │
│   │        └──────────────┼──────────────┘          │  │
│   │                       │                         │  │
│   │              CW20 Base Contract                 │  │
│   │                  (Code ID: 1)                   │  │
│   │                                                  │  │
│   └─────────────────────────────────────────────────┘  │
│                                                         │
└─────────────────────────────────────────────────────────┘
Each token is an instance of the CW20 base contract with unique:
  • Contract address
  • Name and symbol
  • Balances
  • Minter configuration

Use Cases

Governance Tokens

Create tokens for DAO voting and governance

Stablecoins

Issue wrapped stablecoins on XYZ Chain

Reward Tokens

Distribute rewards to users

Utility Tokens

Power in-app economies

Next Steps