Band Protocol
Last updated
Last updated
Band Protocol is a secure, blockchain-agnostic decentralised oracle solution (more detail here). It features a blockchain of its own (BandChain) that does the heavy lifting of pulling data from external sources, aggregating all the results, and creating a verifiable proof of data integrity to be used in other blockchain applications — all with a secure crypto-economic which guarantees data availability and correctness.
Developers building applications on Cronos can now utilise Band’s decentralised oracle services. With Band’s oracle, they now have access to various cryptocurrency price data points to integrate into their applications.
A currency pair is the quotation of two different currencies, with the value of one currency being quoted against the other. The first listed currency of a currency pair is the base currency, and the second currency is called the quote currency. A currency pair compares the value of one currency to another — the base currency versus the quote currency. It indicates how much one unit of the base currency worths in the unit of the quote currency, or, in other words, how much of the quote currency is needed to purchase one unit of the base currency. For instance, in a currency pair CRO/USD
, CRO
is the cryptocurrency Cronos as the base currency, and USD
is the fiat currency U.S. Dollar as the quote currency. The value of currency pair CRO/USD
will indicate how much one CRO
worths in U.S. Dollar.
Currently, one fiat currency - the U.S. Dollar - and the following list of cryptocurrencies are supported. Going forward, this token list will continue to expand based on developers' needs and community feedback.
Token Name | Symbol |
---|---|
Developers are able to query token prices from Band’s oracle through Band’s StdReferenceProxy
contract on Cronos Chain. This contract exposes getReferenceData
and getReferenceDataBulk
functions, to query one currency pair and multiple currency pairs, respectively.
getReferenceData
takes two strings as the inputs — the base and quote symbols respectively. It then queries the StdReference
contract for the latest rate of the specified currency pair, base against quote. The query returns a ReferenceData
struct, shown below:
getReferenceDataBulk
instead takes two lists as inputs: one for the base currencies, and one for the quote currencies. It then proceeds to query the rate for each base/quote pair at each index, and returns an array of ReferenceData
structs.
For example, if we call getReferenceDataBulk(['CRO','WBTC','ETH'], ['USD','ETH','DAI'])
, the returned ReferenceData
array will contain information regarding the following currency pairs:
CRO/USD
WBTC/ETH
ETH/DAI
The contract code below demonstrates a simple example usage of Band's StdReferenceProxy
contract and its getReferenceData
and getReferenceDataBulk
functions.
Copy and paste the above contract into Remix, an online Ethereum IDE;
Specify //SPDX-License-Identifier
, or put // SPDX-License-Identifier: UNLICENSED
if unlicensed, at the first line of the above code;
Compile the contract with compiler version 0.8.13;
Switch to the DEPLOY & RUN TRANSACTIONS tab of Remix;
Select Injected Web3
in the ENVIRONMENT dropdown in the top left to connect with MetaMask;
Make sure that MetaMask is connected to the Cronos testnet, you can refer to our official documentation;
Deploy the contract with the below Cronos testnet Band reference data proxy address;
0xD0b2234eB9431e850a814bCdcBCB18C1093F986B
;
Hooray, you can now fetch the latest supported token prices from Band Protocol!
Network | StdReference Contract Address |
---|---|
Cronos
CRO
Ethereum
ETH
Wrapped Bitcoin
WBTC
Tether
USDT
USD Coin
USDC
Dai
DAI
Cronos Mainnet
Cronos Testnet