Tellor Playground
This page is designed to give you a quick overview of using Tellor to get data into your smart contracts.
Overview
Tellor Playground aims to help anyone building on Tellor to quickly test and implement ideas. See the reference page for deployed addresses on various test networks.
Why use Tellor Playground?
When testing their smart contracts, most projects that want to integrate Tellor only need to test functions for reading and requesting Tellor data.
The Playground is a simplified (and not a real oracle) Tellor, containing only the small bits that developers need to worry about when building and testing: submitting data, getting data, reading events and so forth.
Why not use the real Tellor
There are a few reasons not to use even the testnet version of the real system, the first one being that it is identical to the mainnet version, where there are only so many datapoints available for reading. You can easily get the value of USD or BTC, but if your project needs to read a value from an exotic token, it might not be available.
To include a value in the Rinkeby version, it would first need to be added to the reporter software client. Or a developer could report the value themselves, but they would have to acquire 100 Rinkeby test TRB, stake it, and then they would only be able to submit a value once every 12 hours. If you're testing an idea or building a hackathon project, it might be overkill to go through all of that and it's far easier to make use of Tellor Playground.
How to use
Reading values
If your smart contract needs to read Tellor values, you might want to use the helper usingtellor, which already provides a few helpful functions to fetch data.
The first step is to install usingtellor, then inherit the UsingTellor contract, passing the TellorPlayground address as a constructor argument. Here's an example:
Setting values in the Playground
To be able to properly read a value from playground, you'll need to first set the value yourself, since it does not rely on reporters.
To do that, you can choose some arbitrary queryData
, which is a bytes
value, and then take the keccak256 hash of the queryData
to get the queryId
. For the nonce
, you can always input a value of 0
. Then call submitValue
with any value you wish, which will add a data point to the Playground. Your contract can now easily read Tellor values.
Available Functions
Here are all the functions available in Tellor Playground:
Last updated