Skip to content

quThinh/cosmwasm-contract-template

Repository files navigation

CW20 Token Contract Template

A template for creating CW20-compliant token contracts on Cosmos blockchains. This template provides a basic implementation of the CW20 token standard with common functionality like minting, burning, and transferring tokens.

Features

  • CW20 standard compliance
  • Token minting with optional supply cap
  • Token burning
  • Token transfers
  • Balance and token info queries
  • Configurable token parameters (name, symbol, decimals)

Getting Started

Prerequisites

Building

# Build the contract
cargo build --target wasm32-unknown-unknown --release

# Generate schemas
cargo xtask generate_schemas

# Run tests
cargo test

Contract Instantiation

let msg = InstantiateMsg {
    name: "My Token".to_string(),
    symbol: "MTK".to_string(),
    decimals: 6,
    initial_supply: Uint128::new(1000000),
    minter: Some(minter_address),
};

Available Messages

Execute Messages

  • Transfer: Transfer tokens to another address
  • Mint: Mint new tokens (minter only)
  • Burn: Burn tokens from sender's balance

Query Messages

  • Balance: Query token balance of an address
  • TokenInfo: Query token information (name, symbol, decimals, total supply)
  • Minter: Query minter information

Testing

# Run all tests
cargo test

# Run specific test
cargo test test_cw20_operations

Schema Generation

cargo xtask generate_schemas

This will generate JSON schema files in the schema directory, which can be used for contract interaction and documentation.

License

This project is licensed under the Mozilla Public License 2.0.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Security

This contract has not been audited and is provided as-is. Use at your own risk.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published