LogoLogo
WebsiteDiscordTelegramTwitter
  • 🏠Witnet Oracle Docs
  • Introduction
    • ❓What is Witnet?
      • ⚙️Oracle Architecture
      • 🪙The Witnet Coin (Wit)
      • 👛Wallets
      • 🤔Frequently Asked Questions
      • 😎Awesome Witnet
    • 🚀Quick Tutorials
      • 📈Price Feeds
      • 🎲Randomness
      • 🌐APIs and HTTP GET/POST
      • ⛏️Mining Wit
  • Smart contracts developers
    • ⛓️Supported chains
    • 🔮Wit/Oracle
      • HTTP GET Requests in Solidity
      • HTTP POST Requests in Solidity
      • Query GraphQL APIs in Solidity
      • Dynamic Requests in Solidity
      • UsingWitnet Inheritance
      • API Reference
        • Solidity API
          • Solidity Contracts
            • WitnetRequestBoard
        • Javascript API
        • RADON API
          • RADON Type System
          • RADON Errors
      • Multi-chain Addresses
    • 💹Wit/Price Feeds
      • How To Use Witnet Price Feeds
      • Update Conditions
      • Code Examples
      • API Reference
      • Multi-chain Addresses
        • Arbitrum Price Feeds
        • Avalanche Price Feeds
        • Base Price Feeds
        • Boba Price Feeds
        • Celo Price Feeds
        • Conflux Price Feeds
        • Cronos Price Feeds
        • Dogechain Price Feeds
        • Elastos Price Feeds
        • Ethereum Price Feeds
        • Gnosis Chain Price Feeds
        • Kaia Price Feeds
        • Kava Price Feeds
        • KCC Price Feeds
        • Mantle Price Feeds
        • Meter Price Feeds
        • Metis Price Feeds
        • Moonbeam Price Feeds
        • OKX Price Feeds
        • Optimism Price Feeds
        • Polygon Price Feeds
        • Reef Price Feeds
        • Scroll Price Feeds
        • Syscoin Price Feeds
        • Ultron Price Feeds
        • Request new price feed or chain support
    • 🎲Wit/Randomness
      • Generating Randomness
      • WitnetRandomness Contract
      • Low-level Requests
      • Code Examples
      • API Reference
      • Multi-chain Addresses
    • 🏗️Guides
      • 📖Solidity Contracts
        • Appliances
          • 📃WitnetPriceFeeds
          • 📃WitnetRandomness
        • Core
          • 📃WitnetOracle
          • 📃WitnetRadonRegistry
          • 📃WitnetRequest
          • 📃WitnetRequestFactory
          • 📃WitnetRequestTemplate
        • Mockups
          • 📃UsingWitnet
          • 📃UsingWitnetRandomness
          • 📃UsingWitnetRequest
          • 📃UsingWitnetRequestTemplate
          • 📃WitnetRandomnessRequestConsumer
          • 📃WitnetRequestConsumer
          • 📃WitnetRequestTemplateConsumer
      • 🧙Solidity Wizard
    • 🎓Tutorials
      • Building a Satoshi/Wei custom price feed
  • Witnet Node Operators
    • 🖥️Requirements
    • 🚀Witnet Node Quick Start Guide (Docker)
    • 🔎Next steps
    • 📄CLI Reference
    • 🤓Advanced Setups
      • Run Witnet as a systemd service
      • Run Witnet as a docker compose service
      • Paranoid mode (Witnet over proxies and Tor)
      • Configuration file
  • Witnet Node Developers
    • 🏗️Integration Guide
      • Node API Reference
      • Wallet API Reference
    • 🗜️Compile witnet-rust from Source Code
Powered by GitBook
On this page
  • Using Witnet Price Feeds, in a nutshell
  • What Price Feeds Are Currently Available?
  • Learn More About Witnet Price Feeds

Was this helpful?

Edit on GitHub
  1. Introduction
  2. Quick Tutorials

Price Feeds

PreviousQuick TutorialsNextRandomness

Last updated 4 months ago

Was this helpful?

The easiest way to use an oracle to source external data into a smart contract is through a . More and more projects building on multiple blockchains are relying every day on the WItnet data feeds to get price references and other valuable data into their smart contracts.

Witnet price feeds are timely updated with fresh data as aggregated from multiple reliable data sources and attested by the Witnet decentralized oracle network, which offers high data integrity guarantees thanks to its unique cryptoeconomic design.

Using Witnet Price Feeds, in a nutshell

Using Witnet data feeds to source prices and other data is extremely simple. This example obtains the latest price using the Ethereum Rinkeby testnet:

// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.9.0;

import "witnet-solidity-bridge/contracts/interfaces/IWitnetPriceRouter.sol";

contract MyContract {

    IWitnetPriceRouter public immutable witnetPriceRouter;
    
    /*
     * Network: Ethereum Rinkeby
     * WitnetPriceRouter: 0xa50b17C2fc373c247C3b603f83df6A7800cB0DC9
     **/
    constructor() {
        witnetPriceRouter = IWitnetPriceRouter(0xa50b17C2fc373c247C3b603f83df6A7800cB0DC9);
    }

    /// Returns the BTC / USD price (6 decimals), ultimately provided by the Witnet oracle, and
    /// the timestamps at which the price was reported back from the Witnet oracle's sidechain 
    /// to Ethereum Rinkeby. 
    function getBtcUsdPrice() external view returns (int256 _lastPrice, uint256 _lastTimestamp) {
        (_lastPrice, _lastTimestamp,) = witnetPriceRouter.valueFor(bytes32(0x24beead4));
    }
}

What Price Feeds Are Currently Available?

A complete list of publicly available Witnet data feeds on Witnet's many supported blockchains can be found in the Witnet Data Feeds website:

Learn More About Witnet Price Feeds

The IWitnetPriceRouter and IWitnetPriceFeed interfaces can be found in the , among many other Witnet related interfaces, contracts and utilities.

The section also contains a list of all the data feeds that Witnet provides on the different supported blockchains:

For more information on Witnet price feeds, please read the section dedicated to . This contains a lot more information on alternative ways to consume the data feeds, how they operate, and what their contract addresses are.

🚀
📈
Price Feed
BTC/USD-6
witnet-solidity-bridge npm package
Price Feeds Contract Addresses
Multi-chain Addresses
Witnet Price Feeds
Data Feeds Explorer | Witnet
Logo