Search…
⌃K

Get Started with Price Feeds

Here are detailed guides to help you integrate and implement our services into your smart contracts and decentralized applications. The following details the first service that is live on our TestNet — SupraOracles Price Feeds.
If you're looking for another one of our anticipated services, our devs are hard at work building our suite of next-gen blockchain solutions. Please check back soon for more updates and join our Discord and Telegram communities to stay updated.
These documents are rapidly changing, be sure to consult the documentation often throughout your development lifecycle

Quick Start: S-Value (aka Supra Value) Crypto Price Feeds

Integrating with SupraOracles' price feeds is quick and easy. SupraOracles currently supports several Solidity/EVM-based networks and Move/Aptos/Sui.
Solidity
Sui Move
Aptos Move

Applicable Chains

  • EVM compatible chains
    • Please check Network Addresses for an updated list of all chains that are currently supported

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, first find the S-Value Feed Address for the chain of your choice. When you have the proper address, create an instance of the S-Value Feed using the interface we previously defined as such:
contract ISupraSValueFeedExample {
ISupraSValueFeed internal sValueFeed;
constructor() {
sValueFeed = ISupraSValueFeed(0xA75e54E618aDC67B205aAC7133fA338d2B9d37Ff);
}
}
In this example, we are implementing the S-Value Feed on the BNB TestNet.

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. Open In Remix
// 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(0xA75e54E618aDC67B205aAC7133fA338d2B9d37Ff);
}
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!

More Ways To Use SupraOracles Crypto Price Feeds

S-Value Feeds With Web3.js

// example assumes that the web3 library has been imported and is accessible within your scope
const getEthUsdtPrice = async () => {
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 = '0xA75e54E618aDC67B205aAC7133fA338d2B9d37Ff'
const web3 = new Web3('https://data-seed-prebsc-1-s1.binance.org:8545/')
const sValueFeed = new web3.eth.Contract(abi, address)
const price = (await sValueFeed.methods.checkPrice('eth_usdt').call()).price
console.log(`The price is: ${price}`)
}
getEthUsdtPrice()

S-Value Feeds With ethers.js

1
// example assumes that the ethers library has been imported and is accessible within your scope
2
const getEthUsdtPrice = async () => {
3
////for ethers version 6.0
4
const provider = new ethers.JsonRpcProvider('https://data-seed-prebsc-1-s1.binance.org:8545/')
5
////for ethers version <= 5.7.2
6
//const provider = new ethers.providers.JsonRpcProvider('https://data-seed-prebsc-1-s1.binance.org:8545/')
7
8
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" } ]
9
const address = '0xA75e54E618aDC67B205aAC7133fA338d2B9d37Ff'
10
const sValueFeed = new ethers.Contract(address, abi, provider)
11
const price = (await sValueFeed.checkPrice('eth_usdt')).price
12
13
console.log(`The price is: ${price.toString()}`)
14
}
15
16
getEthUsdtPrice()

Applicable Chains

  • Sui

Step 1: Create The S-Value Framework.

Add the following code to the Sui Move Smart Contract that you wish to retrieve an S-Value.
Directory tree price-oracle-framework
price-oracle-framework/
├── sources
├── SupraOracle.move
├── Move.toml
price-oracle-framework/sources/SupraOracle.move
module SupraOracle::PriceOracle {
use sui::object::UID;
use sui::vec_map::VecMap;
use std::string::String;
struct Entry has store, copy, drop {
value: String,
}
struct OracleHolder has key, store {
id: UID,
feeds: VecMap<String, Entry>,
}
native public fun get_price(_oracle_holder: &OracleHolder, _symbol_bytes: vector<u8>): String;
}
price-oracle-framework/Move.toml
[package]
name = 'SupraOracle'
version = '1.0.0'
[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework", rev = "devnet" }
[addresses]
SupraOracle = "0x7b2061523e53587a12afe4a47dad42a5fe009c97"
This creates the framework that you will later apply in order to fetch a price from SupraOracles.

Step 2: Configure The S-Value Feed Address

Add the SupraOracle dependency and address in your Move.toml
[dependencies]
SupraOracle = { local = "../price-oracle-framework" }

Step 3: Get The S-Value Crypto Price

Now you can simply access the S-Value Crypto Price of our supported market pairs.
  • Import Sui dependency developer-smart-contract/sources/contract.move
use SupraOracle::PriceOracle::{get_price, OracleHolder};
  • Add the following code to developer-smart-contract/sources/contract.move retrieve S-value
public entry fun retrieve_price(
oracle_holder: &mut OracleHolder,
symbol_bytes: vector<u8>
) {
let price = get_price(oracle_holder, symbol_bytes);
// rest code
}
From the above code:
  • OracleHolder : Resource that contains oracle price
  • symbol_bytes: a symbol which you want to retrieve the price value
Tada! You now have a method in your Smart Contract that you can call at any time to retrieve the price of the selected pair.

Applicable Chains

  • Aptos

Step 1: Create The S-Value Framework.

Add the following code to the Sui Move Smart Contract that you wish to retrieve an S-Value.
Directory tree price-oracle-framework
price-oracle-framework/
├── source
├── SupraOracle.move
├── Move.toml
price-oracle-framework/source/PriceOracle.move
module PriceOracle::oracleFactory {
struct Entry has store, copy, drop {
value: std::string::String,
}
native public fun get_price(_oracle: address, symbol_bytes: vector<u8>): Entry;
}
price-oracle-framework/Move.toml
[package]
name = 'PriceOracle'
version = '1.0.0'
[addresses]
PriceOracle = "0x43f274c36df3946b9c20c772420db913337cade9fe1ae85a7d12953bcca59cc2"
Std = "0x1"
AptosFramework = "0x1"
[dependencies]
AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-framework/", rev = "d1e02d627735e2aadf705dedc32d171f39582146" }
This creates the framework that you will later apply in order to fetch a price from SupraOracles.

Step 2: Configure The S-Value Feed Address

Add the PriceOracle dependency and address in your Move.toml
[dependencies]
PriceOracle = { local = './../price-oracle-framework', addr_subst = { 'addresses' = "0x43f274c36df3946b9c20c772420db913337cade9fe1ae85a7d12953bcca59cc2"}}

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 or better yet, as defined in our list above "eth_usdt" by applying the following code to our Smart Contract.
use PriceOracle::oracleFactory;
let price = oracleFactory::get_price(@PriceOracle, b"eth_usdt");
Here's an example of what your implementation should look like.
module OracleClient::SupraSValueFeedExample {
use PriceOracle::oracleFactory;
struct Test has key {
feed_value: oracleFactory::Entry
}
entry fun get_price_feed(account: &signer) acquires Test {
let price = oracleFactory::get_price(@PriceOracle, b"eth_usdt");
if(!exists<Test>(std::signer::address_of(account))) {
move_to(account, Test { feed_value: price });
} else {
let price_feed = borrow_global_mut<Test>(std::signer::address_of(account));
price_feed.feed_value = price;
}
}
}
From the above code:
  • OracleHolder : Resource that contains oracle price
  • symbol_bytes: a symbol which you want to retrieve the price value
Tada! You now have a method in your Smart Contract that you can call at any time to retrieve the price of the selected pair.

Extra: S-Value Feeds with REST API

To check the price feed go to the link below through postman or your browser.
async function get_price_feed() {
let REST_API = "https://fullnode.testnet.aptoslabs.com/v1/accounts/0x43f274c36df3946b9c20c772420db913337cade9fe1ae85a7d12953bcca59cc2/resource/0x43f274c36df3946b9c20c772420db913337cade9fe1ae85a7d12953bcca59cc2::oracleFactory::OracleHolder"
return fetch(REST_API).then(res => res.json());
}