Code Monkey home page Code Monkey logo

cosmwasm-nft's Introduction

COSMWASM-NFT

CircleCI codecov

1. Checkout code and compile

git clone https://github.com/CosmWasm/wasmd.git
cd wasmd
make install

2. Set up a single-node local testnet

# if you've done this before, wipe out all data from last run
# this may wipe out keys, make sure you know you want to do this
rm -rf ~/.wasmd

cd $HOME
wasmd init --chain-id=testing testing

# if you've done this before, check which keys are created locally first
# wasmcli keys list
# you can skip any "add" steps if they already exist
wasmcli keys add validator

wasmd add-genesis-account $(wasmcli keys show validator -a) 1000000000stake,1000000000validatortoken
# You can add a few more accounts here if you wish (for experiments beyond the tutorial)

wasmd gentx --name validator
wasmd collect-gentxs
wasmd start

3. Connecting with a Client

wasmcli config chain-id testing
wasmcli config trust-node true
wasmcli config node tcp://localhost:26657
wasmcli config output json
wasmcli config indent true
# this is important, so the cli returns after the tx is in a block,
# and subsequent queries return the proper results
wasmcli config broadcast-mode block

wasmcli keys add fred
wasmcli keys add bob
wasmcli keys list

# verify initial setup
wasmcli query account $(wasmcli keys show validator -a)

4. Uploading the Code

# for the rest of this section, we assume you are in the same path as the rust contract (Cargo.toml)
cd <path/to/rust/code>

# and recompile wasm
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 \
  confio/cosmwasm-opt:0.7.2

# ensure the hash changed
cat hash.txt

# both should be empty
wasmcli query wasm list-code

# upload and see we create code 1
wasmcli tx wasm store contract.wasm --from validator --gas 42000000 -y
wasmcli query wasm list-code
wasmcli query wasm list-contract-by-code 1

5. Instantiating the Contract

# instantiate contract and verify
INIT="{\"name\":\"wasm-cosmwasm_nft\", \"symbol\":\"WSM\"}"
wasmcli tx wasm instantiate 1 "$INIT" --from validator --amount=50000stake  --label "nft-contract" -y

# check the contract state (and account balance)
wasmcli query wasm list-contract-by-code 1
# contracts ids (like code ids) are based on an auto-gen sequence
# if this is the first contract in the devnet, it will have this address (otherwise, use the result from list-contract-by-code)
CONTRACT=cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5
wasmcli query wasm contract $CONTRACT
wasmcli query account $CONTRACT

cosmwasm-nft's People

Contributors

shiki-tak 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.