Git Product home page Git Product logo

cw-from-zero-to-hero's Introduction

CosmWasm from zero to hero

On Chain Polls

As our first project, we're going to build and store polls on the chain. Its functionality is as follows:

  • Any user can create a poll.
  • Any user can vote on a poll.
  • Polls can have different options.

For a textual example I will talk through a scenario with some users:

  1. User A can create a poll for example:
    • What Cosmos coin is your favorite?
      1. Juno
      2. Osmosis
      3. Cosmos Hub
  2. User A decides to vote on their own poll, they vote for Juno
  3. User B can also vote on the poll, they vote for Cosmos Hub
  4. After a certain amount of time User A (as the owner of the poll) can close the poll. User A closes the poll
  5. User C attempts to vote on a closed poll. They cannot
  6. The poll results are now visible for everyone to see on the chain

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.58.1+) 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: 1.0.0-beta6

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.

cw-from-zero-to-hero's People

Contributors

oakenknight avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.