Giter VIP home page Giter VIP logo

cosmwasm-zero-to-hero's Introduction

Cosmwasm Zero to Hero

The Cosmwasm Tutorial

Hey there, this intends to be a guide on writing your first Cosmwasm contract.

I myself learn by doing so that's what this will cover, I'll provide further pointers below if you want to get deep into the semantics of Cosmwasm.

Other articles:

Donations

This tutorial will remain free and will always be free. If you would like to donate (you are no means required to) here are some addresses to send funds to:

  • Cosmos Hub: cosmos1q06wmnsyqqvuahzev6qfyjs07qs45c9td8jxdy
  • Osmosis: osmo1q06wmnsyqqvuahzev6qfyjs07qs45c9t9upkmk
  • Juno: juno1q06wmnsyqqvuahzev6qfyjs07qs45c9tm43a2c

cosmwasm-zero-to-hero's People

Contributors

callum-a avatar jaybxyz avatar leturt333 avatar llllllluc avatar reecepbcups avatar tacolopo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cosmwasm-zero-to-hero's Issues

build error

environment : mac air m1
replaced with 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
cosmwasm/rust-optimizer-arm64:0.12.4 in script .
when i run ./scripts/deploy_local.sh i get an error saying

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

Error: validator is not a valid name or address: decoding bech32 failed: invalid separator index -1

Error: rpc error: code = NotFound desc = rpc error: code = NotFound desc = account juno1lrt8qk7sefum8vkjdevj0pnwhw4jzs8w47244j not found: key not found
Usage:
junod tx wasm store [wasm file] [flags]
Config Variables

NEXT_PUBLIC_CW_STARTER_CODE_ID=
NEXT_PUBLIC_CW_STARTER_ADDRESS=
1

provided some parts of logs here

Contract Migration?

At the end just having a chapter on contract migration would be useful, took me a bit to learn how to do it via docs.
( This may be a good part-2 to #6 's chapter )

Could be as simple as this

pub struct ConfigResponse {
    pub name: String, // cw2 name
    pub version: String, // cw2 version from the .toml
}

pub const CONFIG = Item<ConfigResponse>

Then a migrate entry point which changes this value on upload

#[entry_point]
pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
    let ver = cw2::get_contract_version(deps.storage)?;
    
    // ensure we are migrating from an allowed contract
    if ver.contract != CONTRACT_NAME {
        return Err(StdError::generic_err("Can only upgrade from same type").into());
    }
    
    if ver.version >= (*CONTRACT_VERSION).to_string() {
        return Err(StdError::generic_err("Cannot upgrade from a newer version").into());
    }

    // set the new version
    cw2::set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

    // state breaking migrations here

    // update the version field in the CONFIG since we have updated the contract
    let mut config = CONFIG.load(deps.storage)?;
    config.version = CONTRACT_VERSION.to_string();
    CONFIG.save(deps.storage, &config)?;

    Ok(Response::default()
        .add_attribute("action", "migration")
        .add_attribute("version", CONTRACT_VERSION)

error: failed to run custom build command for `openssl-sys v0.9.73`

Hello.
I'm following the part Two of the tutorial, while installing the Environment Setup.
I execute this command
cargo install cargo-generate --features vendored-openssl
it compiles some libraries for a while, then ends with
error: failed to run custom build command for openssl-sys v0.9.73``

Why do we always pass env around?

env is always passed from execute and query to the specific execute / query functions, but barely used. Can we just skip passing env?

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.