Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
219 changes: 174 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,173 @@
# CosmWasm

[![CircleCI](https://circleci.com/gh/CosmWasm/cosmwasm/tree/main.svg?style=shield)](https://circleci.com/gh/CosmWasm/cosmwasm/tree/main)
![component][component-badge]
[![license][apache-badge]][apache-url]

[component-badge]: https://img.shields.io/badge/CosmWasm-6343ae.svg
[apache-badge]: https://img.shields.io/badge/License-Apache%202.0-blue.svg
[apache-url]: LICENSE
[notice-url]: NOTICE

**WebAssembly Smart Contracts for the Cosmos SDK**

## Packages

The following packages are maintained here:

| Crate | Usage | Download | Docs | Coverage |
| --------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------ |
| cosmwasm-crypto | Internal only | [![cosmwasm-crypto on crates.io](https://img.shields.io/crates/v/cosmwasm-crypto.svg)](https://crates.io/crates/cosmwasm-crypto) | [![Docs](https://docs.rs/cosmwasm-crypto/badge.svg)](https://docs.rs/cosmwasm-crypto) | [![Coverage][cov-badge-crypto]][cov-link-crypto] |
| cosmwasm-derive | Internal only | [![cosmwasm-derive on crates.io](https://img.shields.io/crates/v/cosmwasm-derive.svg)](https://crates.io/crates/cosmwasm-derive) | [![Docs](https://docs.rs/cosmwasm-derive/badge.svg)](https://docs.rs/cosmwasm-derive) | [![Coverage][cov-badge-derive]][cov-link-derive] |
| cosmwasm-schema | Contract development | [![cosmwasm-schema on crates.io](https://img.shields.io/crates/v/cosmwasm-schema.svg)](https://crates.io/crates/cosmwasm-schema) | [![Docs](https://docs.rs/cosmwasm-schema/badge.svg)](https://docs.rs/cosmwasm-schema) | [![Coverage][cov-badge-schema]][cov-link-schema] |
| cosmwasm-core | Internal only | [![cosmwasm-core on crates.io](https://img.shields.io/crates/v/cosmwasm-core.svg)](https://crates.io/crates/cosmwasm-core) | [![Docs](https://docs.rs/cosmwasm-core/badge.svg)](https://docs.rs/cosmwasm-core) | [![Coverage][cov-badge-core]][cov-link-core] |
| cosmwasm-std | Contract development | [![cosmwasm-std on crates.io](https://img.shields.io/crates/v/cosmwasm-std.svg)](https://crates.io/crates/cosmwasm-std) | [![Docs](https://docs.rs/cosmwasm-std/badge.svg)](https://docs.rs/cosmwasm-std) | [![Coverage][cov-badge-std]][cov-link-std] |
| cosmwasm-vm | Host environments | [![cosmwasm-vm on crates.io](https://img.shields.io/crates/v/cosmwasm-vm.svg)](https://crates.io/crates/cosmwasm-vm) | [![Docs](https://docs.rs/cosmwasm-vm/badge.svg)](https://docs.rs/cosmwasm-vm) | [![Coverage][cov-badge-vm]][cov-link-vm] |
| cosmwasm-check | Contract development | [![cosmwasm-check on crates.io](https://img.shields.io/crates/v/cosmwasm-check.svg)](https://crates.io/crates/cosmwasm-check) | `cosmwasm-check -h` | N/A |

[cosmwasm-storage](https://crates.io/crates/cosmwasm-storage) is no longer
maintained and has been dropped in favor of
[cw-storage-plus](https://github.com/CosmWasm/cw-storage-plus).

[cov-badge-crypto]:
https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-crypto
[cov-badge-derive]:
https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-derive
[cov-badge-schema]:
https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-schema
[cov-badge-core]:
https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-core
[cov-badge-std]:
https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-std
[cov-badge-vm]:
https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-vm
[cov-link-crypto]:
https://codecov.io/gh/CosmWasm/cosmwasm/tree/main/packages/crypto
[cov-link-derive]:
https://codecov.io/gh/CosmWasm/cosmwasm/tree/main/packages/derive
[cov-link-schema]:
https://codecov.io/gh/CosmWasm/cosmwasm/tree/main/packages/schema
## Rust crates

The following Rust crates are maintained in this repository:

| Crate | Usage | Download | Docs | Coverage |
|------------------------------------|----------------------|-----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| cosmwasm‑check | Contract development | [![cosmwasm-check][crates-badge-cosmwasm-check]][crates-url-cosmwasm-check] | [![docs-cosmwasm-check][docs-badge-cosmwasm-check]][docs-url-cosmwasm-check] | ![cov-cosmwasm-check][cov-badge-cosmwasm-check] |
| cosmwasm‑core | Internal use only | [![cosmwasm-core][crates-badge-cosmwasm-core]][crates-url-cosmwasm-core] | [![docs-cosmwasm-core][docs-badge-cosmwasm-core]][docs-url-cosmwasm-core] | ![cov-cosmwasm-core][cov-badge-cosmwasm-core] |
| cosmwasm‑crypto | Internal use only | [![cosmwasm-crypto][crates-badge-cosmwasm-crypto]][crates-url-cosmwasm-crypto] | [![docs-cosmwasm-crypto][docs-badge-cosmwasm-crypto]][docs-url-cosmwasm-crypto] | ![cov-cosmwasm-crypto][cov-badge-cosmwasm-crypto] |
| cosmwasm‑derive | Internal use only | [![cosmwasm-derive][crates-badge-cosmwasm-derive]][crates-url-cosmwasm-derive] | [![docs-cosmwasm-derive][docs-badge-cosmwasm-derive]][docs-url-cosmwasm-derive] | ![cov-cosmwasm-derive][cov-badge-cosmwasm-derive] |
| cosmwasm‑schema | Contract development | [![cosmwasm-schema][crates-badge-cosmwasm-schema]][crates-url-cosmwasm-schema] | [![docs-cosmwasm-schema][docs-badge-cosmwasm-schema]][docs-url-cosmwasm-schema] | ![cov-cosmwasm-schema][cov-badge-cosmwasm-schema] |
| cosmwasm‑schema‑derive | Internal use only | [![cosmwasm-schema-derive][crates-badge-cosmwasm-schema-derive]][crates-url-cosmwasm-schema-derive] | [![docs-cosmwasm-schema-derive][docs-badge-cosmwasm-schema-derive]][docs-url-cosmwasm-schema-derive] | ![cov-cosmwasm-schema-derive][cov-badge-cosmwasm-schema-derive] |
| cosmwasm‑std | Contract development | [![cosmwasm-std][crates-badge-cosmwasm-std]][crates-url-cosmwasm-std] | [![docs-cosmwasm-std][docs-badge-cosmwasm-std]][docs-url-cosmwasm-std] | ![cov-cosmwasm-std][cov-badge-cosmwasm-std] |
| cosmwasm‑vm | Host environments | [![cosmwasm-vm][crates-badge-cosmwasm-vm]][crates-url-cosmwasm-vm] | [![docs-cosmwasm-vm][docs-badge-cosmwasm-vm]][docs-url-cosmwasm-vm] | ![cov-cosmwasm-vm][cov-badge-cosmwasm-vm] |
| cosmwasm‑vm‑derive | Internal use only | [![cosmwasm-vm-derive][crates-badge-cosmwasm-vm-derive]][crates-url-cosmwasm-vm-derive] | [![docs-cosmwasm-vm-derive][docs-badge-cosmwasm-vm-derive]][docs-url-cosmwasm-vm-derive] | ![cov-cosmwasm-vm-derive][cov-badge-cosmwasm-vm-derive] |
| cw‑schema | Contract development | [![cw-schema][crates-badge-cw-schema]][crates-url-cw-schema] | [![docs-cw-schema][docs-badge-cw-schema]][docs-url-cw-schema] | ![cov-cw-schema][cov-badge-cw-schema] |
| cw‑schema‑derive | Internal use only | [![cw-schema-derive][crates-badge-cw-schema-derive]][crates-url-cw-schema-derive] | [![docs-cw-schema-derive][docs-badge-cw-schema-derive]][docs-url-cw-schema-derive] | ![cov-cw-schema-derive][cov-badge-cw-schema-derive] |

[crates-badge-cosmwasm-check]: https://img.shields.io/crates/v/cosmwasm-check.svg
[crates-url-cosmwasm-check]: https://crates.io/crates/cosmwasm-check
[docs-badge-cosmwasm-check]: https://docs.rs/cosmwasm-check/badge.svg
[docs-url-cosmwasm-check]: https://docs.rs/cosmwasm-check
[cov-badge-cosmwasm-check]: https://img.shields.io/badge/coverage-98%25%20%E2%94%82%20100%25%20%E2%94%82%20100%25-21b577.svg

[crates-badge-cosmwasm-core]: https://img.shields.io/crates/v/cosmwasm-core.svg
[crates-url-cosmwasm-core]: https://crates.io/crates/cosmwasm-core
[docs-badge-cosmwasm-core]: https://docs.rs/cosmwasm-core/badge.svg
[docs-url-cosmwasm-core]: https://docs.rs/cosmwasm-core
[cov-badge-cosmwasm-core]: https://img.shields.io/badge/coverage-%E2%80%94%20%E2%94%82%20%E2%80%94%20%E2%94%82%20%E2%80%94-21b577.svg

[crates-badge-cosmwasm-crypto]: https://img.shields.io/crates/v/cosmwasm-crypto.svg
[crates-url-cosmwasm-crypto]: https://crates.io/crates/cosmwasm-crypto
[docs-badge-cosmwasm-crypto]: https://docs.rs/cosmwasm-crypto/badge.svg
[docs-url-cosmwasm-crypto]: https://docs.rs/cosmwasm-crypto
[cov-badge-cosmwasm-crypto]: https://img.shields.io/badge/coverage-81%25%20%E2%94%82%2084%25%20%E2%94%82%2092%25-21b577.svg

[crates-badge-cosmwasm-derive]: https://img.shields.io/crates/v/cosmwasm-derive.svg
[crates-url-cosmwasm-derive]: https://crates.io/crates/cosmwasm-derive
[docs-badge-cosmwasm-derive]: https://docs.rs/cosmwasm-derive/badge.svg
[docs-url-cosmwasm-derive]: https://docs.rs/cosmwasm-derive
[cov-badge-cosmwasm-derive]: https://img.shields.io/badge/coverage-84%25%20%E2%94%82%2085%25%20%E2%94%82%2094%25-21b577.svg

[crates-badge-cosmwasm-schema]: https://img.shields.io/crates/v/cosmwasm-schema.svg
[crates-url-cosmwasm-schema]: https://crates.io/crates/cosmwasm-schema
[docs-badge-cosmwasm-schema]: https://docs.rs/cosmwasm-schema/badge.svg
[docs-url-cosmwasm-schema]: https://docs.rs/cosmwasm-schema
[cov-badge-cosmwasm-schema]: https://img.shields.io/badge/coverage-61%25%20%E2%94%82%2047%25%20%E2%94%82%2065%25-f52020.svg

[crates-badge-cosmwasm-schema-derive]: https://img.shields.io/crates/v/cosmwasm-schema-derive.svg
[crates-url-cosmwasm-schema-derive]: https://crates.io/crates/cosmwasm-schema-derive
[docs-badge-cosmwasm-schema-derive]: https://docs.rs/cosmwasm-schema-derive/badge.svg
[docs-url-cosmwasm-schema-derive]: https://docs.rs/cosmwasm-schema-derive
[cov-badge-cosmwasm-schema-derive]: https://img.shields.io/badge/coverage-76%25%20%E2%94%82%2087%25%20%E2%94%82%2091%25-f4b01b.svg

[crates-badge-cosmwasm-std]: https://img.shields.io/crates/v/cosmwasm-std.svg
[crates-url-cosmwasm-std]: https://crates.io/crates/cosmwasm-std
[docs-badge-cosmwasm-std]: https://docs.rs/cosmwasm-std/badge.svg
[docs-url-cosmwasm-std]: https://docs.rs/cosmwasm-std
[cov-badge-cosmwasm-std]: https://img.shields.io/badge/coverage-92%25%20%E2%94%82%2091%25%20%E2%94%82%2094%25-21b577.svg

[crates-badge-cosmwasm-vm]: https://img.shields.io/crates/v/cosmwasm-vm.svg
[crates-url-cosmwasm-vm]: https://crates.io/crates/cosmwasm-vm
[docs-badge-cosmwasm-vm]: https://docs.rs/cosmwasm-vm/badge.svg
[docs-url-cosmwasm-vm]: https://docs.rs/cosmwasm-vm
[cov-badge-cosmwasm-vm]: https://img.shields.io/badge/coverage-79%25%20%E2%94%82%2083%25%20%E2%94%82%2090%25-f4b01b.svg

[crates-badge-cosmwasm-vm-derive]: https://img.shields.io/crates/v/cosmwasm-vm-derive.svg
[crates-url-cosmwasm-vm-derive]: https://crates.io/crates/cosmwasm-vm-derive
[docs-badge-cosmwasm-vm-derive]: https://docs.rs/cosmwasm-vm-derive/badge.svg
[docs-url-cosmwasm-vm-derive]: https://docs.rs/cosmwasm-vm-derive
[cov-badge-cosmwasm-vm-derive]: https://img.shields.io/badge/coverage-0%25%20%E2%94%82%200%25%20%E2%94%82%200%25-f52020.svg

[crates-badge-cw-schema]: https://img.shields.io/crates/v/cw-schema.svg
[crates-url-cw-schema]: https://crates.io/crates/cw-schema
[docs-badge-cw-schema]: https://docs.rs/cw-schema/badge.svg
[docs-url-cw-schema]: https://docs.rs/cw-schema
[cov-badge-cw-schema]: https://img.shields.io/badge/coverage-63%25%20%E2%94%82%2069%25%20%E2%94%82%2065%25-f4b01b.svg

[crates-badge-cw-schema-derive]: https://img.shields.io/crates/v/cw-schema-derive.svg
[crates-url-cw-schema-derive]: https://crates.io/crates/cw-schema-derive
[docs-badge-cw-schema-derive]: https://docs.rs/cw-schema-derive/badge.svg
[docs-url-cw-schema-derive]: https://docs.rs/cw-schema-derive
[cov-badge-cw-schema-derive]: https://img.shields.io/badge/coverage-0%25%20%E2%94%82%200%25%20%E2%94%82%200%25-f52020.svg

[cov-badge-crypto]: https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-crypto
[cov-badge-derive]: https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-derive
[cov-badge-schema]: https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-schema
[cov-badge-core]: https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-core
[cov-badge-std]: https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-std
[cov-badge-vm]: https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-vm
[cov-link-crypto]: https://codecov.io/gh/CosmWasm/cosmwasm/tree/main/packages/crypto
[cov-link-derive]: https://codecov.io/gh/CosmWasm/cosmwasm/tree/main/packages/derive
[cov-link-schema]: https://codecov.io/gh/CosmWasm/cosmwasm/tree/main/packages/schema
[cov-link-core]: https://codecov.io/gh/CosmWasm/cosmwasm/tree/main/packages/core
[cov-link-std]: https://codecov.io/gh/CosmWasm/cosmwasm/tree/main/packages/std
[cov-link-vm]: https://codecov.io/gh/CosmWasm/cosmwasm/tree/main/packages/vm

## Dependencies

The following diagram shows the dependencies between the Rust crates in this repository:

```mermaid
---
config:
theme: 'forest'
---

graph BT
A("`**cosmwasm-core**
3.0.1`")

B("`**cosmwasm-std**
3.0.1`")

C("`**cosmwasm-crypto**
3.0.1`")

D("`**cosmwasm-vm**
3.0.1`")

E("`**cosmwasm-vm-derive**
3.0.1`")

F("`**cosmwasm-derive**
3.0.1`")

G("`**cosmwasm-schema**
3.0.1`")

H("`**cosmwasm-schema-derive**
3.0.1`")

I("`**cosmwasm-check**
3.0.1`")

J("`**cw-schema**
3.0.1`")

K("`**cw-schema-derive**
3.0.1`")

A --> B
A --> C
A --> D
C --> B
C --> D
B --> D
E --> D
F --> B
H --> G
B --> I
D --> I
G --> B
J --> B
J --> G
K --> J
```

## Overview

To get that contract to interact with a system needs many moving parts. To get
Expand Down Expand Up @@ -74,7 +198,7 @@ This code is compiled into Wasm bytecode as part of the smart contract.
Please submit your contract or interface via PR.
- [rust-optimizer](https://github.com/cosmwasm/rust-optimizer) - A docker image
and scripts to take your Rust code and produce the smallest possible Wasm
output, deterministically. This is designed both for preparing contracts for
output, deterministically. This is designed for preparing contracts for
deployment as well as validating that a given deployed contract is based on
some given source code, allowing a
[similar contract verification algorithm](https://medium.com/coinmonks/how-to-verify-and-publish-on-etherscan-52cf25312945)
Expand Down Expand Up @@ -139,7 +263,7 @@ points, and no access to the outside world by default. To make them useful, we
need to add a few elements.

If you haven't worked with WebAssembly before, please read an overview on
[how to create imports and exports](docs/idl.md) in general.
[how to create imports and exports](docs/IDL.md) in general.

### Exports

Expand Down Expand Up @@ -294,7 +418,7 @@ pub struct Region {
## Implementing the Smart Contract

If you followed the [instructions above](#Creating-a-smart-contract), you should
have a runnable smart contract. You may notice that all of the Wasm exports are
have a runnable smart contract. You may notice that all the Wasm exports are
taken care of by `lib.rs`, which you shouldn't need to modify. What you need to
do is simply look in `contract.rs` and implement `instantiate` and `execute`
functions, defining your custom `InstantiateMsg` and `ExecuteMsg` structs for
Expand Down Expand Up @@ -392,7 +516,7 @@ in our sample contract.
You may also want to ensure the compiled contract interacts with the environment
properly. To do so, you will want to create a canonical release build of the
`<contract>.wasm` file and then write tests with the same VM tooling we will use
in production. This is a bit more complicated but we added some tools to help in
in production. This is a bit more complicated, but we added some tools to help in
[cosmwasm-vm](https://github.com/CosmWasm/cosmwasm/tree/main/packages/vm) which
can be added as a `dev-dependency`.

Expand Down Expand Up @@ -438,9 +562,6 @@ like hashing or signature verification.

## Developing

The ultimate auto-updating guide to building this project is the CI
configuration in `.circleci/config.yml`.

For manually building this repo locally during development, here are a few
commands. They assume you use a stable Rust version by default and have a
nightly toolchain installed as well.
Expand All @@ -458,7 +579,15 @@ nightly toolchain installed as well.
**Contracts**

| Step | Description | Command |
| ---- | -------------------------------- | -------------------------------------- |
|------|----------------------------------|----------------------------------------|
| 1 | fast checks, rebuilds lock files | `./devtools/check_contracts_fast.sh` |
| 2 | medium fast checks | `./devtools/check_contracts_medium.sh` |
| 3 | slower checks | `./devtools/check_contracts_full.sh` |

## License

Licensed under [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
(see [LICENSE][apache-url] and [NOTICE][notice-url]).

Any contribution intentionally submitted for inclusion in this crate by you,
shall be licensed as above, without any additional terms or conditions.