github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/dev/wasm/cw20-base/README.md (about) 1 # CW20 Basic 2 3 This is a basic implementation of a cw20 contract. It implements 4 the [CW20 spec](../../packages/cw20/README.md) and is designed to 5 be deployed as is, or imported into other contracts to easily build 6 cw20-compatible tokens with custom logic. 7 8 Implements: 9 10 - [x] CW20 Base 11 - [x] Mintable extension 12 - [x] Allowances extension 13 14 ## Running this contract 15 16 You will need Rust 1.44.1+ with `wasm32-unknown-unknown` target installed. 17 18 You can run unit tests on this via: 19 20 `cargo test` 21 22 Once you are happy with the content, you can compile it to wasm via: 23 24 ``` 25 RUSTFLAGS='-C link-arg=-s' cargo wasm 26 cp ../../target/wasm32-unknown-unknown/release/cw20_base.wasm . 27 ls -l cw20_base.wasm 28 sha256sum cw20_base.wasm 29 ``` 30 31 Or for a production-ready (optimized) build, run a build command in the 32 the repository root: https://github.com/CosmWasm/cw-plus#compiling. 33 34 ## Importing this contract 35 36 You can also import much of the logic of this contract to build another 37 ERC20-contract, such as a bonding curve, overiding or extending what you 38 need. 39 40 Basically, you just need to write your handle function and import 41 `cw20_base::contract::handle_transfer`, etc and dispatch to them. 42 This allows you to use custom `ExecuteMsg` and `QueryMsg` with your additional 43 calls, but then use the underlying implementation for the standard cw20 44 messages you want to support. The same with `QueryMsg`. You *could* reuse `instantiate` 45 as it, but it is likely you will want to change it. And it is rather simple. 46 47 Look at [`cw20-staking`](https://github.com/CosmWasm/cw-tokens/tree/main/contracts/cw20-staking) for an example of how to "inherit" 48 all this token functionality and combine it with custom logic.