#vm #unit-tests

dev cosmwasm-vm

VM bindings to run cosmwams contracts

18 releases (6 breaking)

✓ Uses Rust 2018 edition

0.7.2 Mar 23, 2020
0.7.0 Feb 26, 2020
0.6.0 Dec 23, 2019
0.5.1 Nov 29, 2019
Download history 10/week @ 2019-12-14 14/week @ 2019-12-21 52/week @ 2019-12-28 31/week @ 2020-01-04 151/week @ 2020-01-11 77/week @ 2020-01-18 5/week @ 2020-01-25 38/week @ 2020-02-01 44/week @ 2020-02-08 126/week @ 2020-02-15 163/week @ 2020-02-22 27/week @ 2020-02-29 88/week @ 2020-03-07 79/week @ 2020-03-14 93/week @ 2020-03-21 91/week @ 2020-03-28

308 downloads per month
Used in 6 crates

Apache-2.0 and maybe MPL-2.0


CosmWasm VM

cosmwasm-vm on crates.io

This is an abstraction layer around the wasmer VM to expose just what we need to run cosmwasm contracts in a high-level manner. This is intended both for efficient writing of unit tests, as well as a public API to run contracts in eg. go-cosmwasm. As such it includes all glue code needed for typical actions, like fs caching.


There are demo files in testdata/contract*.wasm. Those are compiled and optimized versions of contracts/hackatom run through cosmwasm-opt.

To rebuild the test contract, go to the repo root and do

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 \
  confio/cosmwasm-opt:0.7.2 ./contracts/hackatom
cp contracts/hackatom/contract.wasm packages/vm/testdata/contract_0.7.wasm


By default, this repository is built and tested with the singlepass backend. This requires running Rust nighty:

cd packages/vm
cargo +nightly test

To test with Rust stable, you need to switch to cranelift:

cd packages/vm
cargo test --no-default-features --features default-cranelift


This package is part of the cosmwasm repository, licensed under the Apache License 2.0 (see NOTICE and LICENSE).


~181K SLoC