https://github.com/uxdprotocol/uxd-cw20-token
Contract for UXD's cw20-compatible token. Called and instantiated by uxd-contract
https://github.com/uxdprotocol/uxd-cw20-token
Last synced: about 1 year ago
JSON representation
Contract for UXD's cw20-compatible token. Called and instantiated by uxd-contract
- Host: GitHub
- URL: https://github.com/uxdprotocol/uxd-cw20-token
- Owner: UXDProtocol
- License: apache-2.0
- Created: 2022-07-06T15:48:50.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-02T09:28:09.000Z (almost 4 years ago)
- Last Synced: 2025-05-21T17:11:28.576Z (about 1 year ago)
- Language: Rust
- Size: 43.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# UXD cw20-compatible token contract
- will be instantiated and called by uxd-contract (main contract)
- base on cw20-base. in fact calling delegating to cw20-base for all but instantiate
- built using cw-template
# CW20 Basic
This is a basic implementation of a cw20 contract. It implements
the [CW20 spec](https://github.com/CosmWasm/cw-plus/blob/main/packages/cw20/README.md) and is designed to
be deployed as is, or imported into other contracts to easily build
cw20-compatible tokens with custom logic.
Implements:
- [x] CW20 Base
- [x] Mintable extension
- [x] 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/cw-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`](https://github.com/CosmWasm/cw-tokens/tree/main/contracts/cw20-staking) for an example of how to "inherit"
all this token functionality and combine it with custom logic.
## CosmWasm Starter Pack
This is a template to build smart contracts in Rust to run inside a
[Cosmos SDK](https://github.com/cosmos/cosmos-sdk) module on all chains that enable it.
To understand the framework better, please read the overview in the
[cosmwasm repo](https://github.com/CosmWasm/cosmwasm/blob/master/README.md),
and dig into the [cosmwasm docs](https://www.cosmwasm.com).
This assumes you understand the theory and just want to get coding.
## Creating a new repo from template
Assuming you have a recent version of rust and cargo (v1.58.1+) installed
(via [rustup](https://rustup.rs/)),
then the following should get you a new repo to start a contract:
Install [cargo-generate](https://github.com/ashleygwilliams/cargo-generate) and cargo-run-script.
Unless you did that before, run this line now:
```sh
cargo install cargo-generate --features vendored-openssl
cargo install cargo-run-script
```
Now, use it to create your new contract.
Go to the folder in which you want to place it and run:
**Latest: 1.0.0-beta6**
```sh
cargo generate --git https://github.com/CosmWasm/cw-template.git --name PROJECT_NAME
````
**Older Version**
Pass version as branch flag:
```sh
cargo generate --git https://github.com/CosmWasm/cw-template.git --branch --name PROJECT_NAME
````
Example:
```sh
cargo generate --git https://github.com/CosmWasm/cw-template.git --branch 0.16 --name PROJECT_NAME
```
You will now have a new folder called `PROJECT_NAME` (I hope you changed that to something else)
containing a simple working contract and build system that you can customize.
## Create a Repo
After generating, you have a initialized local git repo, but no commits, and no remote.
Go to a server (eg. github) and create a new upstream repo (called `YOUR-GIT-URL` below).
Then run the following:
```sh
# this is needed to create a valid Cargo.lock file (see below)
cargo check
git branch -M main
git add .
git commit -m 'Initial Commit'
git remote add origin YOUR-GIT-URL
git push -u origin main
```
## CI Support
We have template configurations for both [GitHub Actions](.github/workflows/Basic.yml)
and [Circle CI](.circleci/config.yml) in the generated project, so you can
get up and running with CI right away.
One note is that the CI runs all `cargo` commands
with `--locked` to ensure it uses the exact same versions as you have locally. This also means
you must have an up-to-date `Cargo.lock` file, which is not auto-generated.
The first time you set up the project (or after adding any dep), you should ensure the
`Cargo.lock` file is updated, so the CI will test properly. This can be done simply by
running `cargo check` or `cargo unit-test`.
## Using your project
Once you have your custom repo, you should check out [Developing](./Developing.md) to explain
more on how to run tests and develop code. Or go through the
[online tutorial](https://docs.cosmwasm.com/) to get a better feel
of how to develop.
[Publishing](./Publishing.md) contains useful information on how to publish your contract
to the world, once you are ready to deploy it on a running blockchain. And
[Importing](./Importing.md) contains information about pulling in other contracts or crates
that have been published.
Please replace this README file with information about your specific project. You can keep
the `Developing.md` and `Publishing.md` files as useful referenced, but please set some
proper description in the README.
## Gitpod integration
[Gitpod](https://www.gitpod.io/) container-based development platform will be enabled on your project by default.
Workspace contains:
- **rust**: for builds
- [wasmd](https://github.com/CosmWasm/wasmd): for local node setup and client
- **jq**: shell JSON manipulation tool
Follow [Gitpod Getting Started](https://www.gitpod.io/docs/getting-started) and launch your workspace.