#token #cw20 #legacy #contract #compatible #basic #columbus-4

cw20-legacy

Basic implementation of a CosmWasm-20 compliant token compatible with Columbus-4 token

6 releases

0.2.0 Aug 11, 2021
0.2.0-rc2 Aug 6, 2021
0.1.2 Jul 28, 2021

#17 in #cw20

Download history 97/week @ 2024-04-19 61/week @ 2024-04-26 47/week @ 2024-05-03 38/week @ 2024-05-10 34/week @ 2024-05-17 38/week @ 2024-05-24 53/week @ 2024-05-31 35/week @ 2024-06-07 132/week @ 2024-06-14 46/week @ 2024-06-21 17/week @ 2024-06-28 10/week @ 2024-07-05 39/week @ 2024-07-12 129/week @ 2024-07-19 44/week @ 2024-07-26 29/week @ 2024-08-02

242 downloads per month
Used in 2 crates (via cw20-wrapped)

Apache-2.0

83KB
2K SLoC

CW20-Legacy

This version of the CW20 base contract is compatible with the legacy contract running on the Terra chain Columbus-4.

NOTE This contract is modified for the purpose of migration from a Columbus-4 CW20 token contract to Columbus-5. Using the official version of CW20 is strongly recommended for other usages.

This is a basic implementation of a cw20 contract. It implements the CW20 spec and is designed to be deployed as is, or imported into other contracts to easily build cw20-compatible tokens with custom logic.

Implements:

  • CW20 Base
  • Mintable extension
  • Allowances extension

Running this contract

You will need Rust 1.44.1+ with wasm32-unknown-unknown target installed.

You can run unit tests on this via:

cargo test

Once you are happy with the content, you can compile it to wasm via:

RUSTFLAGS='-C link-arg=-s' cargo wasm
cp ../../target/wasm32-unknown-unknown/release/cw20_base.wasm .
ls -l cw20_base.wasm
sha256sum cw20_base.wasm

Or for a production-ready (optimized) build, run a build command in the the repository root: https://github.com/CosmWasm/cosmwasm-plus#compiling.

Importing this contract

You can also import much of the logic of this contract to build another ERC20-contract, such as a bonding curve, overiding or extending what you need.

Basically, you just need to write your handle function and import cw20_base::contract::handle_transfer, etc and dispatch to them. This allows you to use custom ExecuteMsg and QueryMsg with your additional calls, but then use the underlying implementation for the standard cw20 messages you want to support. The same with QueryMsg. You could reuse instantiate as it, but it is likely you will want to change it. And it is rather simple.

Look at cw20-staking for an example of how to "inherit" all this token functionality and combine it with custom logic.

Dependencies

~3.5–5MB
~107K SLoC