LogoLogo
  • The Basics
    • Welcome
    • Fundamentals
    • Contracts Overview
    • Contracts Reference
    • Tutorials
  • Getting Data
    • Introduction
    • Solidity Integration
    • User Checklists
    • Local Testing
    • Testnet
    • Creating a Query
    • Funding a Feed
    • Tellor Functions
    • DataSpecs Registry
    • SnapShot Vote Results
  • Reporting Data
    • Introduction
    • Becoming a Reporter
    • Getting Paid
  • Disputing Data
    • Introduction
    • Monitoring
    • How to Dispute
    • Voting/Resolution
  • Vulnerability Disclosure
Powered by GitBook
On this page
  • Getting a Query ID and Query Data
  • Creating a new Query Type
  • Example QueryData and QueryID
  • Next Steps

Was this helpful?

  1. Getting Data

Creating a Query

PreviousTestnetNextFunding a Feed

Last updated 1 year ago

Was this helpful?

All data reported to Tellor is associated with a unique queryId and a timestamp. When a user requests data using tip and when a reporter submits data using submitValue, they have to input both the queryId and queryData. The queryData tells reporters how to fulfill the data query, while also informing voters how to verify the data in a dispute. The queryId is defined as the keccak256 hash of the queryData field.

In order to query the Tellor oracle you'll need to first generate queryData and its hash, the queryId.

Getting a Query ID and Query Data

Use the tools below to generate a queryId and queryData:

Creating a new Query Type

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:

For example:

What is the price of BTC/USD?

You might formally define your query like this:

Name: SpotPrice

Inputs:

1. asset (string): Asset ID (e.g. btc)

2. currency (string): Selected currency (e.g. usd)

Outputs:

1. price (uint256)

- abi_type: ufixed256x18 (18 decimals of precision)

- packed: false

Example QueryData and QueryID

If you input btc and usd, respectively, the queryData would be:

0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000953706f745072696365000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003627463000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037573640000000000000000000000000000000000000000000000000000000000

and the queryId would be

0xa6f013ee236804827b77696d350e9f0ac3e879328f2a3021d473a0b778ad78ac

Next Steps

If the don't fit your needs you'll need to define a new one.

Register it using site, using this as a .

and the Tellor Team will reach out to help put one together.

Next you need to incentivize reporters to fetch the answer to your question. Please see the section to learn more.

Once Tellor reporters are submitting your new queryType on chain, you can retrieve your desired data with the help of , which is a helper contract that provides various Tellor data getters. You'll first put your question in queryData format, 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 queryId is defined as the keccak256 hash of queryData. Once you know the queryId you'll be able to retrieve your data.

In Solidity, your contract can get data like .

Feel free to start building a query now and integrating it into your project. When you reach the later stages of building your project, to so that data reporters know how to fulfill your query. Please see the next section on how to fund a feed.

existing Query Types
DataSpecs Registry Frontend
this template
Fill out this New Data Request Form
Funding a Feed
UsingTellor
this
add it to the dataSpecs Registry
Tellor Query ID Builder | Decentralized Oracle Protocoltellor | Your Decentralized Oracle
Logo