A CosmWasm Tutorial by Terra Academy.

Overview

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

(Note that recent cargo-generate requires Rust 1.55 features or produces a compile error)

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: 1.0.0-beta

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

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.

Gitpod integration

Gitpod container-based development platform will be enabled on your project by default.

Workspace contains:

  • rust: for builds
  • wasmd: for local node setup and client
  • jq: shell JSON manipulation tool

Follow Gitpod Getting Started and launch your workspace.

You might also like...
Terra liquid staking derivative

Terra liquid staking derivative. Of the community, by the community, for the community.

Outp0st is an open-source UI tool to enable next-level team collaboration on dApp development over Terra blockchain
Outp0st is an open-source UI tool to enable next-level team collaboration on dApp development over Terra blockchain

Outp0st is an open-source UI tool to enable next-level team collaboration on dApp development over Terra blockchain

This monorepository contains the source code for the smart contracts implementing bAsset Protocol on the Terra blockchain.

Crll bAsset Contracts This monorepository contains the source code for the smart contracts implementing bAsset Protocol on the Terra blockchain. You c

Examples and helpers to build NFT contracts on CosmWasm

CosmWasm NFTS This repo is the official repository to work on all NFT standard and examples in the CosmWasm ecosystem. cw721 and cw721-base were moved

Beaker helps simplify CosmWasm development workflow.
Beaker helps simplify CosmWasm development workflow.

Beaker Beaker makes it easy to scaffold a new cosmwasm app, with all of the dependencies for osmosis hooked up, interactive console, and a sample fron

A gRPC-based scripting library for interacting with CosmWasm smart-contracts.

Cosmos Rust Script Smart contract scripting library to ease CosmWasm smart contract development and deployment. cosm-script is inspired by terra-rust-

A simple example demonstrating cross-contract calls in CosmWasm smart contracts

Cross-contract calls This tutorial demonstrates cross-contract calls with CosmWasm v1. Overview An end user calls the reservation contract to register

CosmWasm multi-contract testing framework

Multi Test: Test helpers for multi-contract interactions Warning: Alpha Software Designed for internal use only. This is used for testing cw-plus cont

A Multi-chain Decentralized Exchange (DEX) built on CosmWasm for the WYND DAO.

WynDex A Multi-chain Decentralized Exchange (DEX) built on CosmWasm for the WYND DAO. Overview License The initial pool types were copied from astropo

Owner
Tantatorn Suksangwarn
I'm a computer engineering student at KMITL. I love coding. I'm interested in Machine Learning, Web Development, and so on.
Tantatorn Suksangwarn
Cosmwasm in Cosmwasm through ComposableFi/cosmwasm-vm

Cosmwasmception Running Fastest way to run this contract would be through our vm. But note that our vm runs an already built version this contract, so

Abdullah Eryuzlu 3 Oct 5, 2022
Terra Trophies is a copy of Ethereum's POAP project for Terra

Terra Trophies Terra Trophies is a copy of Ethereum's POAP project for Terra. It allows anyone to create digital badges for participants of events, or

larry.{ust,sol,thor} 18 Dec 7, 2022
CosmWasm-Examples is a collection of example contracts and applications built using the CosmWasm framework

CosmWasm-Examples is a collection of example contracts and applications built using the CosmWasm framework. CosmWasm is a secure and efficient smart contract platform designed specifically for the Cosmos ecosystem.

Vitalii Tsyhulov 20 Jun 9, 2023
CosmWasm/Sylvia counting contract w/ IBC enabled (Cosmos, Rust, CosmWasm, Sylvia)

CosmWasm/Sylvia counting contract w/ IBC enabled (Cosmos, Rust, CosmWasm, Sylvia) This repository contains counting contract created during the study

Alex Cryp 3 Nov 13, 2023
R1cs-tutorial - Tutorial for writing constraints in the `arkworks` framework

Introduction to SNARK Development with `arkworks` In this tutorial, we will learn how to write applications for use with state-of-the-art zkSNARKs usi

arkworks 113 Dec 29, 2022
The NFT smart contract powering xyz on Terra

xyz NFT Contract This repository contains the core NFT smart contract that implements xyz, a base layer for metaverses on the Terra blockchain. The xy

null 16 Sep 25, 2022
Smart Contract for Terra Name Service

TERRA NAME SERVICE CONTRACTS Terra Name Service is to create easy-to-remember names for your Terra address like ‘dokwon.ust’ instead of ‘terra1...whez

null 12 Nov 23, 2022
Smart contracts powering Spectrum Protocol on Terra

Spectrum Core Contracts This monorepository contains the source code for the core smart contracts implementing Spectrum Protocol on the Terra blockcha

Spectrum Protocol 38 Dec 19, 2022
Helper library for interacting with Terra assets (SDK coins and CW20 tokens)

terra-asset Helpers for interacting with Terra assets, including native coins and CW20 tokens Usage This crate contains two struct types: AssetInfo st

larry 9 Jan 3, 2022
Blue Terra is a decentralized protocol for the global democratization of stable and accessible property rights.

??️ The official Blue Terra KYC program. Blue Terra holders interact with this program to activate the leases embedded in their NFTs.

Blue Terra 1 Jan 31, 2022