Skip to content

Commit

Permalink
dapp: Move Band oracle to Tools section
Browse files Browse the repository at this point in the history
  • Loading branch information
aefhm committed Aug 27, 2024
1 parent 2983f57 commit b3dc6ce
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 10 deletions.
File renamed without changes
File renamed without changes
11 changes: 11 additions & 0 deletions docs/dapp/tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Tools & Services

Oasis integrates with a number of services and provides tooling support for
developers using [Remix], [Sourcify], [Docker][localnet], and more. Please
reach out to us on Discord if you are using a tool that has problems
integrating with Oasis.

[Remix]: https://remix.run/docs/en/main
[Sourcify]: https://docs.sourcify.dev/docs/how-to-verify/
[localnet]: https://github.com/oasisprotocol/oasis-web3-gateway/tree/main/docker
[discord]: https://oasis.io/discord
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Integrating BAND oracle smart contract
# Integrating BAND oracle

This guide will explain how to query the Band Protocol reference data smart
contract from another Solidity smart contract on Emerald.
contract from another Solidity smart contract on an Oasis Paratime.

### What is the Band Protocol?

Expand All @@ -10,27 +10,33 @@ platform that aggregates and connects real-world data and APIs to smart
contracts. You can read more about the specific details of the protocol
[here](https://docs.bandchain.org).

### Video Tutorial

<p style={{width: '100%'}}>
<iframe style={{margin: 'auto', display:'block'}} width="560" height="315" src="https://www.youtube.com/embed/cwe6P5MvIfk?si=4QFRA8yJ2PCZB5fq" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</p>

### Deploy Oracle

1. Follow [this link][demooracle-remix] to Remix. The link contains an encoded example `DemoOracle.sol` contract.
2. Compile the contract with compiler version `0.6.11`.
3. Switch to the Deploy tab of Remix.
1. Select "Injected Web3" in the Environment dropdown in the top left to connect Metamask.
2. Make sure that Metamask is connected to the Emerald (Testnet/Mainnet) network. You can read about adding Emerald network to Metamask [here](../../general/manage-tokens/#metamask).
2. Make sure that Metamask is connected to an Oasis Paratime (Testnet/Mainnet) network. You can read about adding a network to Metamask [here](../../general/manage-tokens/#metamask).

![Setting up the environment in Remix](../images/emerald/band_demooracle_smartcontract.png)
![Setting up the environment in Remix](../images/tools/band_demooracle_smartcontract.png)

4. Enter the Emerald Testnet Band reference data aggregator contract address (`0x61704EFB8b8120c03C210cAC5f5193BF8c80852a`) to the `DemoOracle` constructor and deploy the contract. You can access the reference data aggregator contract on mainnet at `0xDA7a001b254CD22e46d3eAB04d937489c93174C3`.
4. Enter the Testnet Band reference data aggregator contract address (`0x61704EFB8b8120c03C210cAC5f5193BF8c80852a`) to the `DemoOracle` constructor and deploy the contract. You can access the reference data aggregator contract on mainnet at `0xDA7a001b254CD22e46d3eAB04d937489c93174C3`.

![Deploying DemoOracle](../images/emerald/band_deploy_demooracle_smartcontact.png)
![Deploying DemoOracle](../images/tools/band_deploy_demooracle_smartcontact.png)

An interface to interact with the contract will appear in the bottom left corner of Remix.

### Get Rates

Clicking the `getPrice` button will return the current price of WBTC in USD. This function calls `getReferenceData(string memory _base, string memory _quote)` on the Band reference data contract, passing "WBTC" and "USD", indicating WBTC as the base and USD as the quote. The rate returned is base/quote multiplied by 1e18.

![Get Rates](../images/emerald/band_get_rates.png)
![Get Rates](../images/tools/band_get_rates.png)

Note that the `DemoOracle` contract only returns the latest rate, but the reference contract also returns values of the last time the base and quote references were updated.

Expand All @@ -40,11 +46,11 @@ Clicking the `getMultiPrices` button returns multiple quotes in the same call, W

The `savePrice` function will save any base/quote rate that is passed to it in the storage variable named `price`. This storage data will only be updated when the “savePrice” function is called, so the saved `price` value will go stale unless this function is called repeatedly.

![Save Price](../images/emerald/band_saveprice.png)
![Save Price](../images/tools/band_saveprice.png)

### Mainnet Reference Data Contract

You can access the reference data aggregator contract on Mainnet at [0xDA7a001b254CD22e46d3eAB04d937489c93174C3](https://explorer.oasis.io/mainnet/emerald/address/0xDA7a001b254CD22e46d3eAB04d937489c93174C3).
You can access the reference data aggregator contract on Mainnet at [0xDA7a001b254CD22e46d3eAB04d937489c93174C3](https://explorer.oasis.io/mainnet/sapphire/address/0xDA7a001b254CD22e46d3eAB04d937489c93174C3).

### Available Reference Data

Expand Down
4 changes: 4 additions & 0 deletions redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ export const redirectsOptions: Options = {
to: 'https://api.docs.oasis.io/sol/sapphire-contracts',
from: '/dapp/sapphire/precompiles' // #688 Migrate dapp/sapphire/precompiles chapter to api.docs.oasis.io
},
{
to: '/dapp/tools/band',
from: '/dapp/emerald/integrating-band-oracle-smart-contract', // #907 Move Band oracle to Tools section
}
],
createRedirects(existingPath) {
// #119 Add /oasis-core/adr/* -> /adrs/* redirection
Expand Down
12 changes: 11 additions & 1 deletion sidebarDapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,17 @@ export const sidebarDapp: SidebarsConfig = {
},
items: [
'dapp/emerald/writing-dapps-on-emerald',
'dapp/emerald/integrating-band-oracle-smart-contract',
],
},
{
type: 'category',
label: 'Tools & Services',
link: {
type: 'doc',
id: 'dapp/tools/README',
},
items: [
'dapp/tools/band',
],
},
],
Expand Down

0 comments on commit b3dc6ce

Please sign in to comment.