Specification | Download | Docs |
---|---|---|
cw0 | ||
cw1 | ||
cw2 | ||
cw3 | ||
cw20 | ||
cw721 |
Contracts | Download | Docs |
---|---|---|
cw1-subkeys | ||
cw1-whitelist | ||
cw3-fixed-multisig | ||
cw20-atomic-swap | ||
cw20-base | ||
cw20-escrow | ||
cw20-staking | ||
cw721-base |
This is a collection of specification and contracts designed for use on real networks. They are designed not just as examples, but to solve real-world use cases, and to provide a reusable basis to build many custom contracts.
If you don't know what CosmWasm is, please check out our homepage and our documentation to get more background. We are running a public testnet you can use to test out any contracts.
Warning None of these contracts have been audited and no liability is assumed for the use of any of this code. They are provided to turbo-start your projects.
Note All code in pre-1.0 packages is in "draft" form, meaning it may
undergo minor changes and additions until 1.0. For example between 0.1 and
0.2 we adjusted the Expiration
type to make the JSON representation
cleaner (before: expires: {at_height: {height: 12345}}
after
expires: {at_height: 12345}
)
The most reusable components are the various cwXYZ specifications under
packages
. Each one defines a standard interface for different domains,
eg. cw20 for fungible tokens,
cw721 for non-fungible tokens,
cw1 for "proxy contracts", etc.
The interface comes with a human description in the READMEs, as well
as Rust types that can be imported.
They contain no logic, but specify an interface. It shows what you need to implement to create a compatible contracts, as well as what interface we guarantee to any consumer of such contracts. This is the real bonus of specifications, we can create an escrow contract that can handle many different fungible tokens, as long as they all adhere to the cw20 specification.
If you have ideas for new specifications or want to make enhancements to existing spec, please raise an issue or create a pull request on this repo.
We provide sample contracts that either implement or consume these
specifications to both provide examples, as well as provide a basis
for code you can extend for more custom contacts, without worrying
about reinventing the wheel each time.
For example cw20-base
is a basic implementation
of a cw20
compatible contract that can be imported in any custom
contract you want to build on it.
CW1 Proxy Contracts:
cw1-whitelist
a minimal implementation ofcw1
mainly designed for referencecw1-subkeys
a simple, but useful implementation, which lets us use a proxy contract to provide "allowances" for native tokens without modifying thebank
module
CW20 Fungible Tokens:
cw20-base
a straightforward, but complete implementation of the cw20 spec along with all extensions. Can be deployed as-is, or imported by other contractscw20-staking
provides staking derivatives, staking native tokens on your behalf and minting cw20 tokens that can be used to claim them. It usescw20-base
for all the cw20 logic and only implements the interactions with the staking module and accounting for pricescw20-escrow
is a basic escrow contract (arbiter can release or refund tokens) that is compatible with all native and cw20 tokens. This is a good example to show how to interact with cw20 tokens.
To compile all the contracts, run the following:
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.10.3
This will compile all packages in the contracts
directory and output the
stripped and optimized wasm code under the artifacts
directory as output,
along with a checksums.txt
file.
If you hit any issues there and want to debug, you can try to run the
following in each contract dir:
RUSTFLAGS="-C link-arg=-s" cargo build --release --target=wasm32-unknown-unknown --locked
This repo contains two license, Apache 2.0 and
AGPL 3.0. All crates in this repo may be licensed
as one or the other. Please check the NOTICE
in each crate or the
relevant Cargo.toml
file for clarity.
All specifications will always be Apache-2.0. All contracts that are meant to be building blocks will also be Apache-2.0. This is along the lines of Open Zepellin or other public references.
Contracts that are "ready to deploy" may be licensed under AGPL 3.0 to encourage anyone using them to contribute back any improvements they make. This is common practice for actual projects running on Ethereum, like Uniswap or Maker DAO.