• Stars
    star
    283
  • Rank 146,066 (Top 3 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created about 5 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Quickstart template to get started writing your own cosmwasm contracts

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 installed (via rustup), then the following should get you a new repo to start a contract:

Install cargo-generate and cargo-run-script. Unless you did that before, run this line now:

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

cargo generate --git https://github.com/CosmWasm/cw-template.git --name PROJECT_NAME

For cloning minimal code repo:

cargo generate --git https://github.com/CosmWasm/cw-template.git --name PROJECT_NAME -d minimal=true

Older Version

Pass version as branch flag:

cargo generate --git https://github.com/CosmWasm/cw-template.git --branch <version> --name PROJECT_NAME

Example:

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:

# 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 and Circle CI 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 to explain more on how to run tests and develop code. Or go through the online tutorial to get a better feel of how to develop.

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 the Developing.md and Publishing.md files as useful referenced, but please set some proper description in the README.

More Repositories

1

cosmwasm

Framework for building smart contracts in Wasm for the Cosmos SDK
Rust
1,060
star
2

cw-plus

Production Quality contracts under open source licenses
Rust
506
star
3

wasmd

Basic cosmos-sdk app with web assembly smart contracts
Go
367
star
4

awesome-cosmwasm

😎 Curated list of tools, contracts, and projects working with CosmWasm
242
star
5

wasmvm

Go bindings to the CosmWasm VM
Go
173
star
6

optimizer

Dockerfile and script to deterministically produce the smallest possible Wasm for your Rust contract
Rust
123
star
7

ts-codegen

Convert your CosmWasm smart contracts into dev-friendly TypeScript classes so you can focus on shipping code.
TypeScript
116
star
8

sylvia

CosmWasm smart contract framework
Rust
93
star
9

mesh-security-hackathon

Implementation of Sunny's Mesh Security talk (Hackathon / Prototype status)
Rust
88
star
10

cw-tokens

Examples of cw20 usage, extracted from cw-plus, maintained by the community
Rust
85
star
11

dApps

A collection of sample dApps for CosmWasm contracts, using CosmJS frontend SDK
TypeScript
55
star
12

docs-deprecated

Updated documentation repo
JavaScript
52
star
13

CosmWasmJS

Source of the cosmwasm npm package
TypeScript
50
star
14

cw-multi-test

CosmWasm multi-contract testing framework
Rust
46
star
15

cw-storage-plus

Storage abstractions for CosmWasm smart contracts
Rust
35
star
16

testnets

Information on all public CosmWasm testnets
TypeScript
34
star
17

book

CosmWasm book
34
star
18

cosmwasm-go

Enabling CosmWasm smart contracts in Go using TinyGo
Go
29
star
19

token-factory

Pulling out Osmosis token factory module and the custom CosmWasm bindings into it's own repo for easier reuse
Go
24
star
20

resources

23
star
21

tinyjson

Fast JSON serializer for golang.
Go
22
star
22

code-explorer

A code explorer for CosmWasm
TypeScript
21
star
23

cw-minus

Contract helpers originally used for cw-plus contracts/specs
Rust
16
star
24

cosmwasm-verify

Verify CosmWasm build results
Shell
15
star
25

advisories

To publicly communicate advisories about serious bugs in CosmWasm, wasmvm, and wasmd
Shell
14
star
26

drand-verify

A drand verification library in Rust. This can be used by other crates or be compiled to a Wasm blob (< 500 kilobytes) with JavaScript bindings.
Rust
12
star
27

cosmwasm-simulate

Simulation tool for cosmwasm smart contract
Rust
10
star
28

cw-academy-course

CosmWasm academy smart contracts course projects
Rust
7
star
29

mesh-security-ui

Basic UI to try out mesh security
TypeScript
6
star
30

docs

MDX
6
star
31

token-bindings

Minimal Rust bindings for token factory
Rust
5
star
32

CWIPs

CosmWasm Improvement Proposals
Shell
5
star
33

storey

Experimental storage abstractions for blockchain key-value stores
Rust
5
star
34

academy-deploy

TypeScript
4
star
35

cw-cron

Basic job scheduler service implementation for CosmWasm
3
star
36

sylvia-book

3
star
37

name-app

Simple react app on top of cosmwasm, showing use of name server contract
TypeScript
3
star
38

terra-contracts

Custom bindings and sample contracts for Terra integration
Rust
2
star
39

cw-mcs-academy-course

Repository for multi contract systems academy course
Rust
2
star
40

docs-old

Documentation for cosmwasm
JavaScript
2
star
41

simple-option

Demo repo for hackatom video
Rust
2
star
42

cw-storage

CosmWasm library with useful helpers for Storage patterns
Rust
1
star
43

chat.cosmwasm.com

Redirect to our community chat
HTML
1
star
44

cw-tools

Rust
1
star
45

idl

The CosmWasm IDL docs
1
star
46

sylvia-template

Rust
1
star