Giter Club home page Giter Club logo

cross-contract-call's Introduction

CROSS CONTRACT CALL

A simple demonstration of cross contract call in cosmwasm

Overview

Simple demonstration of Cross Contract Call using Counter example.

When an end user executes message in Counter1 it increases it counter and pass the message to Contract Counter2 . Contract Counter2 increases the count after sucessfully exectuing the message received form Counter1.

This is a trivial example to demonstrate cross-contract calls.

We can query the count from Counter1 to see how many times the message has been success fully executed in Conuter2

HOW TO DEPLOY

  • Crate WASM binary of the contracts by running

    cargo wasm or RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --lib

  • Initialize the terminal and set the ENV by running

    source <(curl -sSL https://raw.githubusercontent.com/CosmWasm/testnets/master/malaga-420/defaults.env)

  • Deploy generated WASM binary

    RES=$(wasmd tx wasm store <WASM_BINARY_PATH> --from <WALLET_ADDRESS> $TXFLAG -y --output json -b block)

  • Extract the Contract CODE_ID from Result of previous execution

    CODE_ID=$(echo $RES | jq -r '.logs[0].events[-1].attributes[0].value')

  • Instantiate contract by provinding Instantiate message

    wasmd tx wasm instantiate $CODE_ID "$INIT" --from <WALLET_ADDRESS> --label "<LABEL>" $TXFLAG -y --no-admin

  • Get the contract address

    CONTRACT=$(wasmd query wasm list-contract-by-code $CODE_ID $NODE --output json | jq -r '.contracts[-1]')

Now you can execute messages , query results from the contract using contract address.

cross-contract-call's People

Contributors

shreyasbhat0 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.