HomeCoinsBand Protocol (BAND)Understanding Band Oracle #2 — Requesting Information on BandChain

Understanding Band Oracle #2 — Requesting Information on BandChain

- Advertisement -


Understanding Band Oracle #2 — Requesting Information on BandChain

Understanding Band Oracle #2 — Requesting Information on BandChain

Preface

This text is the second a part of a sequence wherein we’ll discover how Band Protocol’s oracle system operates and its constituents. The sequence consists of three fundamental parts:

1. Information Sources and Oracle Scripts

Within the first half, we went over the 2 fundamental parts of BandChain’s oracle system; knowledge sources and oracle scripts. Particularly, we outlined the 2 ideas and the way they relate to every different.

2. Requesting Information on BandChain

Within the second half, coated on this article, we’ll clarify the precise course of that happens when somebody submits a knowledge request to BandChain, how the info sources and oracle scripts match into the move . This part will cowl each the person processes that make up the move and the strategies that we will use to make the requests ourselves.

3. BandChain Lite Consumer Verification

Lastly, within the final a part of the sequence, we’ll describe the method that makes up BandChain’s lite consumer verification protocol and the way a knowledge requester can use it to confirm the integrity and validity of the end result they acquired from BandChain.

Understanding Band Oracle #2 — Requesting Information on BandChain

Introduction

An information request to BandChain’s oracle could be made in two methods:

We’ll cowl truly use these two strategies later within the article. First, let’s go over what truly occurs on the BandChain decentralized oracle community when a knowledge request is made.

Information Request Circulate

When somebody makes a request to BandChain’s oracle, they should specify the next parameters:

  • the oracle script ID they need to name
  • the parameters for use within the oracle script specified
  • the variety of validators they want to reply to the request
  • the minimal variety of validators required to answer qualify as a profitable request

As soon as they’ve made the request specifying the above parameters and the related transaction is confirmed on BandChain, the requested oracle script will start its execution.

Understanding Band Oracle #2 — Requesting Information on BandChain

The move after this level can then be cut up into two sections:

  1. fetching the info from the info sources (preparation part)
  2. aggregating the request’s outcomes onto Bandchain (aggregation part)

Fetching Information from the Specified Information Sources

First, the oracle script’s preparation perform will emit the set of information sources obligatory to satisfy the request. The validators, that have been chosen based mostly on a randomized stake-weighted algorithm to answer the request, will then examine the info requests and execute the related knowledge sources' procedures as instructed by the request.

Particularly, every of the chosen validators will try to retrieve data from the entire knowledge sources specified within the executed oracle script, bettering resistance to manipulation via a number of redundancies. The validators that efficiently retrieved knowledge from all of the sources will then submit a uncooked knowledge report, containing the outcomes they retrieved, to BandChain. If sufficient validators efficiently submit these experiences, BandChain will start executing the oracle script’s aggregation part.

Aggregating the Request Outcomes onto BandChain

The aggregation part begins by aggregating the entire validators’ experiences right into a single end result. This closing result’s then completely saved in BandChain’s software state. As soon as saved, the end result turns into out there on the chain’s state tree and could be despatched to different blockchains.

Understanding Band Oracle #2 — Requesting Information on BandChain

When the ultimate result’s efficiently saved, an oracle knowledge proof can be produced. This proof is a Merkle proof that reveals the existence of the ultimate results of the info request in addition to different associated data (oracle script hash, the parameters, the time of execution, and so on.) on BandChain.

This proof can then be utilized by good contracts on different blockchains to confirm the existence of the info on BandChain in addition to to decode and retrieve the end result saved. Each of those could be finished by interacting with our lite consumer, which is able to clarify within the subsequent and closing a part of this sequence.

Understanding Band Oracle #2 — Requesting Information on BandChain

Making a Information Request

As talked about above, there are two fundamental methods of requesting knowledge from BandChain; via the CosmoScan or utilizing the BandChain.js package deal.

Requesting Information through CosmoScan

The primary method of submitting a knowledge request is thru BandChain’s offered explorer.

Understanding Band Oracle #2 — Requesting Information on BandChain

To take action, go to https://guanyu-devnet.cosmoscan.io. There you will see our devnet explorer with data on BandChain. From there, navigate to the Oracle Scripts tab on the highest left nook.

Understanding Band Oracle #2 — Requesting Information on BandChain

On the oracle script web page, you will notice a listing of the entire oracle scripts at present out there on BandChain. BandChain’s Devnet comes with many pre-defined oracle scripts, which you’ll discover the spec on the left-hand sidebar of this documentation. On this walkthrough, we’ll experiment utilizing the Yahoo inventory worth oracle script.

Understanding Band Oracle #2 — Requesting Information on BandChain

On the oracle script’s web page, you will notice varied tabs containing data associated to the script, together with:

  • its execution parameters
  • its Owasm code
  • its Bridge code to encode and decode the script’s enter and output structs
  • a historical past of all of the requests that have been made to this script
  • a historical past of the entire revisions made on this script

We’ll proceed with execute tab to create our first knowledge request to BandChain.

Understanding Band Oracle #2 — Requesting Information on BandChain

Below Execute tab, we will specify the execution parameters for our request. On this case, we’ll specify GOOGL (Google inventory ticker) because the image and 1 because the multiplier.

Understanding Band Oracle #2 — Requesting Information on BandChain

As soon as we have now enter the parameters, we then hit the Request button. The explorer will maintain sending the message to BandChain.

As soon as the validators have retrieved the knowledge and the ultimate result’s saved on BandChain, the explorer will present the transaction hash of the request, the ultimate end result (1420), in addition to the proof of validity.

Requesting Information through BandChain.js Library

Understanding Band Oracle #2 — Requesting Information on BandChain

Alternatively, as an alternative of manually making the requests utilizing the explorer, a knowledge request may also be made utilizing the offered BandChain.js NodeJS library. This enables builders to submit knowledge requests proper from their dApp consumer.

As soon as BandChain has efficiently executed the requested knowledge request and oracle script, it should return the info and proof payload again to the consumer to then be handed to your good contracts.

To indicate an instance requesting knowledge utilizing the library, we’ll write a easy Node file that queries the present Google inventory worth (GOOGL) from BandChain. The total code is proven under.

https://medium.com/media/29d434b23876e76c29911b23f8c5ddae/href

Let’s undergo every part of the code.

Importing the Required Libraries

https://medium.com/media/3b67970b461fcbdb4e4032fd81106877/href

The instance code requires two libraries

  • @bandprotocol/obi.js: a helper library to help us when encoding/decoding knowledge to/from Band Protocol's OBI commonplace
  • @bandprotocol/bandchain.js: the library that we'll be utilizing to make the queries to BandChain

Setting the Request Parameters

https://medium.com/media/ba9ed47593c0232176221422f7ec4f17/href

Right here we set the values that we’ll be utilizing to make the request

  • endpoint: the endpoint we’ll make the question to
  • mnemonic: the mnemonic we’ll use to make the question. The related account will need to have a stability to make a request
  • oracleScriptID: the ID of the oracle script that we’ll be executing to retrieve the knowledge
  • minCount: the minimal variety of BandChain's validators that responds for us to think about the request profitable
  • askCount: the utmost variety of validators that we need to reply to the request
  • gasAmount/gasLimit: transaction fuel config

Instantiating the Mandatory Variables and Objects

https://medium.com/media/4261610968aa13bb47d2fe0b43ea79c1/href

After we have now declared the bottom variable we’d like, we will start to make the request.

We start by creating a brand new bandchain class object from the desired endpoint variable. The BandChain class incorporates the required capabilities we'll must make the request.

We then retrieve data associated to the oracle script we need to execute to get the requested knowledge.

Following that, we create a brand new obi object that we’ll use to decode the end result we obtain from BandChain.

Making the Oracle Request and Getting the Outcomes

https://medium.com/media/c545bc3135157344058d9d45a7bbc33b/href

Lastly, we execute the submitRequestTx member perform of the beforehand created bandchain object to make the oracle knowledge request.

We are able to then do one in every of two issues almost about this request:

  • Name getRequestResult, as we did right here, to get the precise results of the request
  • Name getRequestProof to get the proof bytes related to the request

Each of those capabilities soak up one argument, the requestID of the request you need to retrieve the end result/proof from.

If the question is profitable, the code ought to print a price much like:{ px: 91795049n }.

Understanding Band Oracle #2 — Requesting Information on BandChain

Wrapping Up

This text goals to supply an summary of the method when a knowledge request is made to BandChain’s oracle. Within the subsequent and closing a part of this sequence, we’ll discover BandChain’s lite consumer verification mechanics used for cross-chain compatibility, and the way the info requester can confirm the validity of the outcomes they acquired.

For probably the most up to date and detailed directions on make requests on BandChain and use the ends in your good contract, please see our developer documentation.

About Band Protocol

Band Protocol is a cross-chain knowledge oracle platform that aggregates and connects real-world knowledge and APIs to good contracts. Blockchains are nice at immutable storage and deterministic, verifiable computations — nevertheless, they can’t securely entry knowledge out there exterior the blockchain networks. Band Protocol permits good contract functions comparable to DeFi, prediction markets, and video games to be constructed on-chain with out counting on the only level of failure of a centralized oracle. Band Protocol is backed by a robust community of stakeholders together with Sequoia Capital, one of many prime enterprise capital corporations on this planet, and the main cryptocurrency trade, Binance.

Web site | Whitepaper | Telegram | Medium | Twitter | RedditGithub

Understanding Band Oracle #2 — Requesting Information on BandChain


Understanding Band Oracle #2 — Requesting Information on BandChain was initially printed in Band Protocol on Medium, the place persons are persevering with the dialog by highlighting and responding to this story.





Learn the unique article right here

- Advertisement -
Mr Bitcointehttps://www.bitcointe.com/
“Fact You Need To Know About Cryptocurrency - The first Bitcoin purchase was for pizza.” ― Mohsin Jameel
462FansLike
76FollowersFollow
4,567FollowersFollow
5,261FollowersFollow
1,581FollowersFollow
2,230SubscribersSubscribe

Most Popular

bitcoin
Bitcoin (BTC) $ 42,415.00
ethereum
Ethereum (ETH) $ 2,939.61
tether
Tether (USDT) $ 1.00
bitcoin-cash
Bitcoin Cash (BCH) $ 319.74
litecoin
Litecoin (LTC) $ 124.94
eos
EOS (EOS) $ 2.39
okb
OKB (OKB) $ 21.05
tezos
Tezos (XTZ) $ 4.20
leo-token
LEO Token (LEO) $ 5.76
cardano
Cardano (ADA) $ 1.08
monero
Monero (XMR) $ 170.04
stellar
Stellar (XLM) $ 0.216748
chainlink
Chainlink (LINK) $ 16.10
huobi-token
Huobi Token (HT) $ 9.95
tron
TRON (TRX) $ 0.063986
usd-coin
USD Coin (USDC) $ 1.00
dash
Dash (DASH) $ 103.88
neo
NEO (NEO) $ 21.87
iota
IOTA (MIOTA) $ 0.871745
nem
NEM (XEM) $ 0.107252
zcash
Zcash (ZEC) $ 118.01
maker
Maker (MKR) $ 2,019.28
paxos-standard
Pax Dollar (USDP) $ 0.998487
ethereum-classic
Ethereum Classic (ETC) $ 32.48
vechain
VeChain (VET) $ 0.057534
true-usd
TrueUSD (TUSD) $ 1.00
ftx-token
FTX Token (FTT) $ 43.92
kucoin-shares
KuCoin Token (KCS) $ 19.00
waves
Waves (WAVES) $ 9.68