Tellor Docs
Search…
Requesting / Paying for Data
Anyone staked reporter can place data on-chain regardless of whether it is requested or payed for. If however you do not want to report your own data, you can request data using the Autopay contract.

Getting a Data ID

To check out our current supported data types and/or use our tool to make a new one, checkout our querybuilder: https://queryidbuilder.herokuapp.com/

Funding a one time request

To tip a query ID for an instant report (whoever submits the value next gets the reward), you just need to run one function:
1
/**
2
* @dev Function to run a single tip
3
* @param _queryId id of tipped data
4
* @param _amount amount to tip
5
* @param _queryData the data used by reporters to fulfill the query
6
*/
7
function tip(
8
bytes32 _queryId,
9
uint256 _amount,
10
bytes calldata _queryData
11
) external
Copied!
be sure to approve the transfer of the token before you call the function.

Funding a recurring data feed

To fund a data feed, you will need to run two functions, one to set up the feed and the other to fund it. If a fund is already set up with your specifications, you can simply call the function to fund it.
To set up your data feed:
1
/**
2
* @dev Initializes dataFeed parameters.
3
* @param _queryId id of specific desired data feet
4
* @param _reward tip amount per eligible data submission
5
* @param _startTime timestamp of first autopay window
6
* @param _interval amount of time between autopay windows
7
* @param _window amount of time after each new interval when reports are eligible for tips
8
* @param _queryData the data used by reporters to fulfill the query
9
*/
10
function setupDataFeed(
11
bytes32 _queryId,
12
uint256 _reward,
13
uint256 _startTime,
14
uint256 _interval,
15
uint256 _window,
16
bytes calldata _queryData
17
) external {
Copied!
As an example, if on Polygon you want to tip 1 TRB token each hour for the spot BTC price. You need it every hour, starting tomorrow, and you need it updated within 5 minutes of the hour.
1
_queryId =0xa6f013ee236804827b77696d350e9f0ac3e879328f2a3021d473a0b778ad78ac (keccak256 of queryData)
2
_reward = 1000000000000000000 (1 TRB)
3
_startTime = 1647435600 (tomorrow start time (UNIX))
4
_interval = 3600 (seconds in hour)
5
_window = 300 (seconds in 5 minutes)
6
_queryData = 0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000953706f745072696365000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003627463000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037573640000000000000000000000000000000000000000000000000000000000
7
//_queryData = abi.encode("SpotPrice",abi.encode("btc","usd"))
Copied!
To fund the feed:
1
/**
2
* @dev Allows dataFeed account to be filled with tokens
3
* @param _feedId unique dataFeed Id for queryId
4
* @param _queryId id of reported data associated with feed
5
* @param _amount quantity of tokens to fund feed account
6
*/
7
function fundFeed(
8
bytes32 _feedId,
9
bytes32 _queryId,
10
uint256 _amount
11
) external
Copied!
The _feedId is simply the keccak256 has of the variables defined in setupFeed:
1
bytes32 _feedId = keccak256(
2
abi.encode(
3
_queryId,
4
_token,
5
_reward,
6
_startTime,
7
_interval,
8
_window,
9
_priceThreshold
10
)
11
);
Copied!
The _amount is the amount of the token you would want to fund it with. For example, if you are tipping 1 TRB per hour, if you fund the feed with 24 TRB, it would pay out for the next 24 hours.
Be sure to approve the token transfer before calling this function.