|Jan 5, 2022
#43 in #oracle
40 downloads per month
Used in loterra
CosmWasm Starter Pack
This is a template to build smart contracts in Rust to run inside a Cosmos SDK module on all chains that enable it. To understand the framework better, please read the overview in the cosmwasm repo, and dig into the cosmwasm docs. 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.47.0+) installed (via rustup), then the following should get you a new repo to start a contract:
First, install cargo-generate. Unless you did that before, run this line now:
cargo install cargo-generate --features vendored-openssl
Now, use it to create your new contract. Go to the folder in which you want to place it and run:
cargo generate --git https://github.com/CosmWasm/cosmwasm-template.git --name PROJECT_NAME
cargo generate --git https://github.com/CosmWasm/cosmwasm-template.git --branch 0.12 --name PROJECT_NAME
cargo generate --git https://github.com/CosmWasm/cosmwasm-template.git --branch 0.11 --name PROJECT_NAME
cargo generate --git https://github.com/CosmWasm/cosmwasm-template.git --branch 0.10 --name PROJECT_NAME
cargo generate --git https://github.com/CosmWasm/cosmwasm-template.git --branch 0.9 --name PROJECT_NAME
cargo generate --git https://github.com/CosmWasm/cosmwasm-template.git --branch 0.8 --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
Then run the following:
# this is needed to create a valid Cargo.lock file (see below)
git checkout -b master # in case you generate from non-master
git add .
git commit -m 'Initial Commit'
git remote add origin YOUR-GIT-URL
git push -u origin master
One note is that the CI runs all
--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
cargo check or
Using your project
Publishing 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 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
Publishing.md files as useful referenced, but please set some
proper description in the README.