Reading Data
Last updated
Last updated
To use Tellor data, import , our helper contract for any network, connect it to the Oracle, and read a value on your queryId
. This quickstart uses the BTC/USD SpotPrice
as an example query.
Just import the UsingTellor contract into your solidity file passing the desired Tellor address (see ) as a parameter.
Once we've created a queryId
, we're ready to add our Tellor data feed to our contract code. The best-practice for reading Tellor data is to use the function getDataBefore
. We use this function to leave time for disputes. In the example below, we'll add to the snippet above a function getBtcSpotPrice()
that reads the btc/usd price feed from the Oracle.
The Playground is a simplified (and not a real oracle) Tellor, containing only the small bits that developers need to worry about: getting data, adding tips, reading events and so forth.
When finished testing with the Playground, switching back to the real Tellor only requires updating the oracle address in your UsingTellor implementation.
aims to help anyone building on Tellor to quickly bootstrap, implement, and test a Tellor integration. See the for deployed addresses on various test networks.
Implementing the Playground is as simple as pointing the UsingTellor
constructor to the Playground on your network. See the for deployed addresses on various test networks.