LogoLogo
  • DFK Developer Docs
  • Contracts
    • Exchanges
      • The Trader
      • The Bazaar
    • Sales & Rentals
      • Hero Auction
      • Hero Rental
      • Equipment Auction
      • Pet Auction
      • Land Auction
    • Summoning
      • Hero Summoning
        • Dark Summoning
      • Pet Hatching
    • Meditation Circle
    • Quests
      • Quest Core
      • Historical Contracts
        • Quest Core
        • Profession Quests
        • Training Quests
    • Void Hunts
    • Patrols
    • PVP Combat
    • Influence System
    • Gardens
      • Master Gardener
    • Jeweler 2.0
      • Power-Ups
      • Jeweler 1.0
    • Profiles
    • DFK Duel
      • Previous Seasons
      • Raffle Master
    • Events
      • Gen0 Reroll
      • Gene Reroll
      • Perilous Journey
    • Bridging
      • Hero Bridge (Synapse)
      • Hero Bridge (LayerZero)
      • Equipment Bridge (Synapse)
      • Equipment Bridge (LayerZero)
      • Item Bridge V2
        • Item Bridge V1 (Deprecated)
      • Gaia's Tear Bridge
    • Miscellaneous
      • Airdrops
      • Charity
      • Flag Storage
      • Gen0 Airdrop (Harmony)
      • Gen0 Sale (Harmony)
      • Graveyard
      • Locked Token Claim
      • Locked Token Raffle
      • Token Disburse
  • NFTs
    • Heroes
      • HeroV4 (Metis)
    • Equipment
      • Weapons
      • Armor
      • Accessories
      • Shared Equipment Mappings
      • CacheCore
      • Equipment Shop
      • Visage Shop
    • Pets
      • Pet Exchange
    • Lands
  • Tokens
    • Ecosystem Token
    • Power Tokens
    • Governance Tokens
    • Currencies
      • DFK Gold
      • Gaia's Tears
    • Inventory Items
    • Gold Crops
    • Combat Items
    • Miscellaneous Tokens
      • Collectible Items
      • Raffle Tickets
  • Crafting
    • Alchemist
    • Nutritionist
    • Stone Carver
    • Vendor (Item Gold Trader)
  • Collections
    • Runes
    • Pet Eggs
    • Pet Treats
    • Potions & Consumables
      • Item Consumer
      • Potion Migrator
    • Enhancement Stones
    • Attunement Crystals
      • Atonement Crystals
    • Pages of the Eternal Story
  • API
    • Community GraphQL API
      • Getting Started
      • Auctions
      • Bazaar
      • Heroes
      • Pets
      • Profiles
    • Hero Metadata & Image API
    • Pet Metadata & Image API
    • Token Supply API
  • Community Builders
    • Kingdom Building Program
    • Developer Resources
    • Community Projects
  • DFK CHain
    • Getting Started
    • Nodes & Validators
    • Bridged Tokens
    • Ecosystem Partners
      • Covalent API
      • SupraOracles Price Feeds
      • SupraOracles VRF
    • Miscellaneous Contracts
Powered by GitBook
On this page
  • What is SupraOracles?
  • How to use SupraOracles' Price Feeds
  • Going Further with SupraOracles
  • Connect with us!
  1. DFK CHain
  2. Ecosystem Partners

SupraOracles Price Feeds

PreviousCovalent APINextSupraOracles VRF

Last updated 1 year ago

What is SupraOracles?

is a novel, high-throughput Oracle & IntraLayer: a vertically integrated toolkit of cross-chain solutions (data oracles, asset bridges, automation network, and more) that interlink all blockchains, public (L1s and L2s) or private (enterprises).

How to use SupraOracles' Price Feeds

Integrating with SupraOracles' Price Feeds is quick and easy. SupraOracles currently supports many Solidity/EVM-based networks, like DFK Chain TestNet, and non-EVM networks such as Sui and Aptos.

To see all of the networks SupraOracles supports, please visit !

To get started, you will want to visit and review the documentation or continue to follow this guide for a quick start.

Step 1: Create The S-Value Interface

Add the following code to the Solidity smart contract that you wish to retrieve an S-Value.

interface ISupraSValueFeed {
    function checkPrice(string memory marketPair) external view returns (int256 price, uint256 timestamp);
}

This creates the interface that you will later apply in order to fetch a price from SupraOracles.

Step 2: Configure The S-Value Feed Address

To fetch the S-Value from a SupraOracles smart contract, you must first find the S-Value Feed Address for the chain of your choice.

For DFK Chain TestNet, the address is: 0x700a89Ba8F908af38834B9Aba238b362CFfB665F

When you have the proper address, create an instance of the S-Value Feed using the interface we previously defined for DFK Chain TestNet:

contract ISupraSValueFeedExample {
    ISupraSValueFeed internal sValueFeed;

    constructor() {
        sValueFeed = ISupraSValueFeed(0x700a89Ba8F908af38834B9Aba238b362CFfB665F);
    }
}

Step 3: Get The S-Value Crypto Price

Now you can simply access the S-Value Crypto Price of our supported market pairs. In this step, we'll get the price of ETH/USDT (eth_usdt) by applying the following code to our Smart Contract.

function getEthUsdtPrice() external view returns (int) {
    (
        int price,
        /* uint timestamp */
    ) = sValueFeed.checkPrice("eth_usdt");

    return price;
}

Here's an example of what your implementation should look like

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;


interface ISupraSValueFeed {
    function checkPrice(string memory marketPair) external view returns (int256 price, uint256 timestamp);
}

contract ISupraSValueFeedExample {
    ISupraSValueFeed internal sValueFeed;

    constructor() {
        sValueFeed = ISupraSValueFeed(0x700a89Ba8F908af38834B9Aba238b362CFfB665F);
    }

    function getEthUsdtPrice() external view returns (int) {
        (
            int price,
            /* uint timestamp */
        ) = sValueFeed.checkPrice("eth_usdt");

        return price;
    }
}

Tada! You now have a method in your Smart Contract that you can call at any time to retrieve the price of ETH in USDT!

Extra: S-Value Feeds with ethers.js

// example assumes that the ethers library has been imported and is accessible within your scope
const getEthUsdtPrice = async () => {
  const provider = new ethers.providers.JsonRpcProvider('https://data-seed-prebsc-1-s1.binance.org:8545/')
  const abi = [{ "inputs": [ { "internalType": "string", "name": "marketPair", "type": "string" } ], "name": "checkPrice", "outputs": [ { "internalType": "int256", "name": "price", "type": "int256" }, { "internalType": "uint256", "name": "timestamp", "type": "uint256" } ], "stateMutability": "view", "type": "function" } ]
  const address = '0x700a89Ba8F908af38834B9Aba238b362CFfB665F'
  const sValueFeed = new ethers.Contract(address, abi, provider)
  const price = (await sValueFeed.checkPrice('eth_usdt')).price

  console.log(`The price is: ${price.toString()}`)
}

getEthUsdtPrice()

Going Further with SupraOracles

The Supra Network Activate Program (SNAP) offers companies discounted oracle credits, technical documentation, and customer support to embed much-needed oracles and VRF/RNG. SNAP supports Web3 scaling and growth to buffer costs which could typically inhibit a company’s success.

The SNAP program is partnered with some of Web3's most prolific names who are helping with project selection and qualification.

Connect with us!

Still looking for answers? We got them! Check out all the ways you can reach us:

For additional tutorials and guides based on example use-cases, please refer to the .

If you want to take the next step, consider registering for the .

Visit us at

Read our

Chat with us on

Follow us on

Join our

Check us out on

SupraOracles
SupraOracles' Networks
SupraOracles' docs site
Supra docs
Supra Network Activate Program (SNAP)
supraoracles.com
Docs
Telegram
Twitter
Discord
Youtube