Coder Social home page Coder Social logo

interchainqueries's Introduction

Interchainqueries

The purpose of this repository is to demonstrate the capabilities and usage of the x/icq module. This module can create cross-chain queries where one would be able to retrieve the balance of an Account on another IBC connected chain or Spot-Price from Osmosis. This module only works with the following GO Relayer.

DISCLAIMER

This code is unaudited and untested, it is only for demonstrational purposes to show how one can implement an end to end trustless query from one IBC connected blockchain to another. We do not assume any responsibility for any loss of funds due to the use of this code.

Notes

ICQ can perform periodic queries from a source chain to a target chain. The query will only read a KV store of the target chain and not the normal GRPC endpoint as the GRPC endpoint cannot provide Proofs to validate our results. Read more about the module in the DESIGN DOCS.

Get started

starport chain serve -c config-icq-1.yml

serve command installs dependencies, builds, initializes, and starts your blockchain in development.

Example Periodic Query

An example periodic query which will query the balance of an account on the target chain.

  path := "/store/bank/key"
  clientId := "07-tendermint-0"
  chainId := "test-2"
  queryModuleAddress := "test_module_address"

  add1, _ := sdk.AccAddressFromBech32("icq17dtl0mjt3t77kpuhg2edqzjpszulwhgzp4faq3")
  icqPeriodic := types.PeriodicICQ{
    Path:                 path,
    TimeoutHeightPadding: uint64(20),
    TargetHeight:         uint64(0),
    ClientId:             clientId,
    Creator:              queryModuleAddress,
    ChainId:              chainId,
    QueryParameters:      append(banktypes.CreateAccountBalancesPrefix(add1), []byte("stake")...),
    BlockRepeat:          uint64(10),
    LastHeightExecuted:   uint64(ctx.BlockHeight()),
    MaxResults:         uint64(10),
  }
  k.AppendPeriodicICQ(ctx, icqPeriodic)

Once the result is received one can convert the raw data to the exact type as such:

var balance sdk.Coin
cdc.MustUnmarshal(data, &balance)

Which will be converted to a balance of X stake tokens.

Research Resources

interchainqueries's People

Contributors

vitalyv1337 avatar

Stargazers

 avatar Amir avatar Larry avatar Mike Purvis avatar Justin Tieri avatar Amnot avatar billy rennekamp avatar

Watchers

Dylan Frendo avatar Francesco Cremona avatar  avatar

Forkers

nextnet-works

interchainqueries's Issues

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.