Getting Started

In this quick guide, we will help you add OrFeed to your smart contract.

Here's a quick tutorial video that explains the basics of OrFeed.

At the top of your smart contract or in a referenced file in your dApp project, include this interface.

interface OrFeedInterface {
  function getExchangeRate ( string fromSymbol, string toSymbol, string venue, uint256 amount ) external view returns ( uint256 );
  function getTokenDecimalCount ( address tokenAddress ) external view returns ( uint256 );
  function getTokenAddress ( string symbol ) external view returns ( address );
  function getSynthBytes32 ( string symbol ) external view returns ( bytes32 );
  function getForexAddress ( string symbol ) external view returns ( address );


To initialize OrFeed, simply include this code in your smart contract:

OrFeedInterface orfeed= OrFeedInterface(0x8316b082621cfedab95bf4a44a1d4b64a6ffc336);

Get The Current Price

One of the best things about OrFeed is that OrFeed automatically detects which kind of asset you are looking for (though the data can come from different providers), as the parameter of "venue" when making the getExchangeRate call. For example, you can get the price for ETH/USD the same way you get the price for JPY/ETH.

//the third blank parameter is venue or the oracle code that you would like to receive the data from, as there can be multiple oracles providing data on the same pair. Blank is the default oracle for a pair.
uint jpyusdPrice = orfeed.getExchangeRate("JPY", "USD", "DEFAULT", 100000);
// returns 920 (or $920.00)

As solidity does not have decimals, all responses are in integers. To determine how many decimals you should calculate with, you can call the getTokenDecimalCount external function for both your assets in the conversion. If you receive a response of 0, either the pair you are sending is not included in the free feed, you are requesting a premium feed and not subscribed, or oracles for the subscriber OrFeed premium feed do not yet support it (and you can fix this by becoming an OrFeed oracle!). Most popular crypto tokens and five of the most popular forex pairs are included in the free feed, and will always remain free.

Note: Replace "DEFAULT" with the oracle provider you would like data from. For example, if you want to know Uniswap's price on the buy side, use "BUY-UNISWAP-EXCHANGE". If you want Kyber's sell side data for the same, you can use "SELL-KYBER-EXCHANGE". Because ERC-20s have many, many integers and zero decimals (in the actual smart contracts), when getting prices from token to token, be sure to use very large amounts.... 1000000000 DAI is less than one penny, for example, due to divisibility at 18.

Other Examples

uint price = orfeed.getExchangeRate("ETH", "USDC", "BUY-KYBER-EXCHANGE", 100000000000000);

uint price = orfeed.getExchangeRate("BTC", "DAI", "SELL-UNISWAP-EXCHANGE", 100);

uint price = orfeed.getExchangeRate("MKR", "EUR", "", 100000000000000);

uint price = orfeed.getExchangeRate("AAPL", "USD", "PROVIDER1", 1);

You can register a provider name and connect it to your custom oracle contract (DNS-style) via the OrFeed Oracle Registry: here by calling the registerOracle function. An example of an oracle smart contract that will be compatible with the OrFeed proxy contract is available in /contracts/examples/ProvideDataExamples/userGeneratedOracleExample.sol on Github (very simple example that either returns 500 or 2) Once you deploy your contract and register it to the registry (paying a small amount of ETH to prevent spamming of names), you can check/verify your registration by calling the getOracleAddress function.
As more reputable, as well as trustless, oracle smart contracts register within the OrFeed registry, we will update a new list as a reference.

The above are all examples of synchronous data for pricing. More docs regarding grabbing asynchronous pricing, as well as event outcome data, from Chainlink, Augur, and other data providers coming soon.


Try out the getExchangeRate method here:

To test full functionality, please visit the Dapp Page On Etherscan

OrFeed Oracle Network

Here's a quick 1-pager (click to download PDF) that explains the basics of how the OrFeed oracle network works:

All free price data comes from decentralized platforms on the Ethereum blockchain, such as Kyber Network, Uniswap Exchange and Synthetix. These mostly include cryptocurrency, foreign exchange and some public equity prices.
Many dApps need/will need access to pricing data from specific exchanges for the above (free) assets or other data like ETF, mutual fund, bond, interest rate, or other data. These feeds are provided by the OrFeed Oracle Network.

But how does this work?

It's quite simple. Anyone can become an OrFeed provider, granted they can stake Ethereum. Currently, it costs .5 ETH as a deposit (stake) to provide a feed for one pair. If the prices you provide deviate by 2% or more (this becomes tighter as more adoption arrives) at any moment, your funds are sent to the OrFeed DAO, and others can purchase that feed to become the provider. The price to become a provider of a feed increases based on the demand and systematic risk that oracles provide to OrFeed subscribers.

To subscribe to OrFeed, users simply send in the monthly subscribers' fee (set each month by the OrFeed DAO and currently .05ETH). This grants unlimited access to all premium feeds to a users' smart contract. 90% of all subscription costs (rents) are sent to the feed provider. 10% is sent to the OrFeed DAO to monitor and police the accuracy of feed provider data.

Join The OrFeed Network

Currently, OrFeed is in alpha. To be one of the first to receive the smart contract address for purchasing OrFeed provisions as soon as its release, please send an email with the subject "Orfeed Oracle Network" to Sign-up form coming soon. Emails will be sent in the order they are received.

Contribute To OrFeed

We welcome you to join us in providing the most reliable pricing data to Ethereum dApps! If you see anything wrong, have ideas, or would like to add a feature, please send a pull request on our develop branch here.