Tellor Docs
Search…
Tellor Playground
This page is designed to give you a quick overview of using Tellor to get data into your smart contracts.

TL:DR

Tellor Playground aims to help anyone building on Tellor quickly test and implement ideas. See the reference page below for the contract addresses on all testnets.

Why use Tellor Playground?

The Tellor Core repository is a large project that holds all the on-chain logic of the system, but a lot of the code there is aimed at dealing with stakers, miners, disputes, etc. which most projects that want to ask and read Tellor values don't really need to worry about.
The Playground is a simplified (and not a real oracle) Tellor, containing only the small bits that third-party developer projects integrating need to worry about: getting data, adding tips, reading events and so forth.

Why not use the real Tellor?

There are a few reasons why using the test version of the real system makes sense. The first one being that it is identical to the mainnet version, where only 50 data points are 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 created at Tellor Improvement Proposal(TIPs), which will be analyzed by the community and if there's no opposition, it'll go for implementation and then it'll be available on testnet. 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 inherit the UsingTellor contract, passing the TellorPlayground address as a constructor argument:
Here's an example
1
contract BtcPriceContract is UsingTellor {
2
3
//This Contract now have access to all functions on UsingTellor
4
5
uint256 btcPrice;
6
uint256 btcRequetId = 2;
7
8
constructor(address payable _tellorAddress) UsingTellor(_tellorAddress) public {}
9
10
...
11
}
Copied!

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 miners.
To do that, you can choose an arbitrary requestId, which is an uint256, and call the function submitValue with any value you wish. This will add a data point to the Playground and save the timestamp which was submitted. Your contract can now easily read Tellor values.

Available Functions

Here are all the functions available in Tellor Playground:
1
/**
2
* @dev A mock function to submit a value to be read without miners needed
3
* @param _requestId The tellorId to associate the value to
4
* @param _value the value for the requestId
5
*/
6
function submitValue(uint256 _requestId,uint256 _value) external;
7
8
/**
9
* @dev A mock function to create a dispute
10
* @param _requestId The tellorId to be disputed
11
* @param _timestamp the timestamp that indentifies for the value
12
*/
13
function disputeValue(uint256 _requestId, uint256 _timestamp) external;
14
15
/**
16
* @dev Retreive value from oracle based on requestId/timestamp
17
* @param _requestId being requested
18
* @param _timestamp to retreive data/value from
19
* @return uint value for requestId/timestamp submitted
20
*/
21
function retrieveData(uint256 _requestId, uint256 _timestamp) public view returns(uint256);
22
23
/**
24
* @dev Gets if the mined value for the specified requestId/_timestamp is currently under dispute
25
* @param _requestId to looku p
26
* @param _timestamp is the timestamp to look up miners for
27
* @return bool true if requestId/timestamp is under dispute
28
*/
29
function isInDispute(uint256 _requestId, uint256 _timestamp) public view returns(bool);
30
31
/**
32
* @dev Counts the number of values that have been submited for the request
33
* @param _requestId the requestId to look up
34
* @return uint count of the number of values received for the requestId
35
*/
36
function getNewValueCountbyRequestId(uint256 _requestId) public view returns(uint);
37
38
/**
39
* @dev Gets the timestamp for the value based on their index
40
* @param _requestId is the requestId to look up
41
* @param index is the value index to look up
42
* @return uint timestamp
43
*/
44
function getTimestampbyRequestIDandIndex(uint256 _requestId, uint256 index) public view returns(uint256);
45
46
/**
47
* @dev Adds a tip to a given request Id.
48
* @param _requestId is the requestId to look up
49
* @param _amount is the amount of tips
50
*/
51
function addTip(uint256 _requestId, uint256 _amount) external;
Copied!
Tellor Playground is also an ERC20 token, and if you want to add tips to your request, you might need to get some test tokens. For that there's an available function:
1
/**
2
* @dev Public function to mint tokens for the passed address
3
* @param user The address which will own the tokens
4
*
5
*/
6
function faucet(address user) external;
Copied!
Last modified 9mo ago