Creating a Query
All data reported to Tellor is associated with a unique queryId and a timestamp. When a user requests data using
tipand when a reporter submits data using
submitValue, they have to input both the
queryDatatells reporters how to fulfill the data query, while also informing voters how to verify the data in a dispute. The
queryIdis defined as the keccak256 hash of the
In order to query the Tellor oracle you'll need to first generate
queryDataand its hash, the
Use the tools below to generate a
To add a new data type to Tellor, you'll just need to define a new queryType. This is how you form a question so that Tellor reporters know exactly what data is being requested.
To create a new Query Type, or specification, for custom data you need from Tellor oracles, there are two options:
You'll need to determine three things: a unique queryType name, inputs, and outputs. So let's say you want a query for getting the price of any asset in any currency. In human-readable form, your question could look like this:
What is the price of BTC/USD?
You might formally define your query like this:
1. asset (string): Asset ID (e.g. btc)
2. currency (string): Selected currency (e.g. usd)
1. price (uint256)
abi_type: ufixed256x18 (18 decimals of precision)
Once Tellor reporters are submitting your new queryType on chain, you can retrieve your desired data with the help of UsingTellor, which is a helper contract that provides various Tellor data getters. You'll first put your question in
queryDataformat, which means encoding your queryType name and arguments into bytes (see below). You'll then need to get a
queryId, which is the bytes32 unique identifier for each Tellor data feed. The
queryIdis defined as the keccak256 hash of
queryData. Once you know the
queryIdyou'll be able to retrieve your data.
If you input
usd, respectively, the
Feel free to start building a query now and integrating it into your project. When you reach the later stages of building your project, add an issue to Tellor's dataSpecs repository so that data reporters know how to fulfill your query. Please see the next section on how to fund a feed.