Skip to content

Latest commit

 

History

History
85 lines (47 loc) · 6.03 KB

File metadata and controls

85 lines (47 loc) · 6.03 KB

Supra Oracles

Overview

Supra is a novel, high-throughput Oracle & IntraLayer offering a vertically integrated toolkit of cross-chain solutions. These solutions include data oracles, asset bridges, and automation networks that aim to interlink all public and private blockchains. Supra provides decentralized Oracle price feeds to deliver real-world data to web3 ecosystems through various on-chain and off-chain use cases. Oracles ensure that the data from the real world is accurate, which is crucial for decentralized applications (dApps) that rely on real-world, real-time data. This is important for dApps that need real-time information, such as the prices of cryptocurrencies and various other assets. The Supra x Hedera integration aims to bring speed, security, and accuracy to real-time data feeds, enhancing the functionality and reliability of dApps on the Hedera network.

Developer Considerations

Contract calls, such as eth_call and eth_estmateGas, go to the mirror node, which limits those to a small data payload size. Our engineering team has successfully upgraded the API call data payload capacity to 24 KB. This enhancement is designed to fetch a single price pair from the data feed efficiently, ensuring a more streamlined retrieval process.

{% hint style="info" %} Please Note: While this update offers improved performance to pull single price pairs, attempting to pull more than one price pair at a time may surpass the new 24 KB data payload limit. Should this limit be exceeded, the API will return an error message. We recommend structuring your API calls accordingly to avoid any potential disruptions. {% endhint %}

Official Documentationsupra-oracles7134.jpghttps://docs.supra.com/
🔮 HBAR Price Feedhedera-logo-black.pnghttps://supra.com/data/details?instrumentName=hbar_usd&providerName=supra

Supra Demo on Hedera

Data Feeds - Pull Model

Pull Model

This example shows how to use Supra Oracles real-world data feeds (Pull model). It fetches and verifies price data from Supra's gRPC server and use it within a smart contract on the Hedera network. These are key files:

main.js

This main script interfaces with the Supra Oracle to request price data proofs for a specified pair. It demonstrates the initialization of a PullServiceClient, the request for data proofs, and the interaction with a smart contract deployed on Hedera to deliver the obtained price data.

The script enables switching between the Hedera mainnet and testnet environments. It uses Web3.js and includes functions to sign and send transactions to Hedera, estimate gas, and extract price data.

MockOracleClient.sol

This Solidity smart contract acts as a mock client for consuming Oracle pull data. It defines a structure for the price data and a function to receive and process the verified Oracle proof bytes.

Try this Example on Your Browser with GitPod

  1. Go to this link

  2. Run the following commands on the terminal:

    cd client npm init --y npm install

  3. Rename the file .env.SAMPLE to .env and enter you Hedera network credentials (testnet/mainnet):

    cp .env.SAMPLE .env

  4. Run the main.js script:

    node main.js

You should see a console output similar to:

Console Output

Data Feeds - Push Model

Push Model

This example shows how to use Supra Oracles real-world data feeds (Push model).

main.js

With this script, you start by deploying the ConsumerContract.sol and passing to its constructor the Supra storage contract address (storageContractAddress). Get the right storage address from: https://supra.com/docs/data-feeds/decentralized/networks/

Then call the getPrice and/or getPriceForMultiplePair functions using the desired price pair indices. Get the right price pair indices from: https://supra.com/docs/data-feeds/data-feeds-index/

Try this Example on Your Browser with GitPod

  1. Go to this link

  2. Run the following commands on the terminal:

    npm install

  3. Rename the file .env.SAMPLE to .env and enter you Hedera network credentials (testnet/mainnet):

    cp .env.SAMPLE .env

  4. Run the main.js script:

    node main.js

Console Output