Sirwin
Sirwin

Tellor School – Tellor Query ID Builder 

By Tamsay | Tellor | 28 Jun 2022


Links 

Youtube link: https://www.youtube.com/watch?v=thjXi7FGLpU 

Official links: https://linktr.ee/ 

 

Summary 

Hey everybody, welcome to another episode of Tellor school. In this exercise we will be going over how to use the Tellor query id builder. Now this is a specific tool that we built for the Tellor ecosystem if you're not familiar with what a query id is, this video might be a little advanced for you and you might still need to do the first step which is implementing Tellor into your solidity code. I'll throw a link to where you can get that started in the docs below but let's go ahead and dive into the query id builder I'm going to go ahead and share my screen here now not a lot going on here quite yet we just wanted to keep it very simple but we have our basic description of what a query id is the unique identifier of a query type for data that's requested reported entry by Tellor oracles so again this is going to be the unique identifier for let's say the Ethereum usd price so that when you are integrating into your code and you are requesting this data the reporters know exactly which type of data you're looking for and can report on it accurately now one key nuance I want to make very clear here is that we're simply just building the question and producing an id for it this idea will work in tandem with the Tellor data specs GitHub repo which the reporters are going to be referencing for what kind of answer this question is asking for so if you're not going to be using one of the already established data specs in the Tellor GitHub or if you have a brand new question that you want to be asking the Tellor ecosystem I'll throw a link in the description below for where you can get started on that but I just wanted to preface this with a little context as I will be going back and forth between the query builder and the Tellor data specs repo but going back to the tool we're just going to go ahead and click here to get started and right now we have two avenues that you can go down obviously spot price is a more popular request than the DeFi ecosystem. So, we just wanted to give an easy access user experience for those users and really all that needs to happen here is you're going to have your ticker symbol make sure they're all lower case as an uppercase will change the query id entirely and this is just what's been standardized for the reporter network so we already have a kind of a suggested field here but I'm going to go ahead and put the btc usd price and we're just going to hit generate id. And what you'll see here is a descriptor which you're not going to necessarily need for your code but it is good for record keeping purposes, the query data which is going to hold all of that price data and then the query id which is the hashed version of this query data so you can have a unique and uniform id that the reporters can easily read and pull the right data. Also, you'll see the clipboards here these are going to be your copy and paste easy access buttons here you can just simply click it and it'll put that entire id in your copy function ready to be pasted into your code. Next let's go to the custom route as it has a little bit more nuance to it. The first field here will be designating the query type as you'll see here on the spot price example spot price type has already been designated as we know that you're already in that realm so you'll just need to fill in the ticker symbols. But with custom type data basically anything outside of a spot price we're going to need to parse them out in different types as there's going to be a lot more information to digest so that the reporters can know exactly what they need to be reporting on. So, for this example I'm actually going to use the gas price oracle as we've already done it and it's something we can verify with some code and it's also a very good example of what kind of things we're looking for when you're generating a query id for your custom data. So, just quickly hopping over to the GitHub I'm going to go to the list of available data types I'm going to find the gas price oracle and then we'll take a look at what we have going on here. So, obviously we have the type name already designated here I'm just going to go ahead and copy this and put it in our type name so this is the first argument that we will be designating. So, now that we've designated the query type name, we just need to fill out the arguments that make up this query type so the reporters know exactly what they need to be pulling. There's going to be two fields here one is the type of data that we're going to be requesting is it an address is it a uint256 and then the actual argument value. So, if we go back to our specs here the first parameter slash argument that we're going to be needing is the chain id as we all know different chains have different gas prices so we will need to designate firstly which chain the reporters need to report the gas price on so if we go here the description is the unique id of the EVM chain and the value type is uint256. So, just going back to the builder here we'll select uin256 and then we'll use the same as the example here ring could be which is four now once we fill this first argument in you will see we have two selections here we can either add another argument or you can generate the query id with the inputs that we have as is going back to a reference point on the data specs repo we will see there are two arguments slash parameters that we need to use here so we're going to add argument and this is just going to bring down another line to address the same fields that we just did for the chain id. So, if we go to the data specs that we're going to be pulling the timestamp which is the unix timestamp to calculate on chain gas price at and the value type will again be you and 256. so, we'll go ahead and just select you and again here and for this we're going to go to this epic converter site and it's actually just going to give us the current timestamp so we'll just go and take this right now and plop that into the argument value so now we have completed as many arguments as are necessary for this specific data spec obviously you can continue to add more if you like but for this specific instance, we only need the two I can even go ahead and delete these last two that I just added and we can go ahead and generate the id. So, you'll see here we have the same breakout as we did for the spot price the query descriptor the query data and then the query id hash itself. And then once you have your query id the next step will be to fund your feed using the autopay smart contract which we will go over in another Tellor school video. All right and there you have it so hopefully this tool is useful for you as you're building on Tellor but that's going to do it for this video and we will see you on the next Tellor school, thanks for watching. 

 

 

How do you rate this article?

1



Tellor
Tellor

In this blog I will post transcriptions of videos made by the Tellor team.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.