New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Tellor 🛠 Getting Tellor Data For Any Use case - Tim Kernell

ETHGlobalMon, Oct 9, 2023, 12:00 AM

Join Tim Kernell of Tellor for a workshop titled "Getting Tellor Data For Any Use case" Thank you for joining us for ETHSanFrancisco—our first west-coast hackathon in nearly four years. This was officially our biggest event ever 🎉 👥 1700 attendees 🗺 from 46 countries 🌱 38% new to web3 📮 284 projects And: ETHGlobal just turned five! 5️⃣🎂 Thanks to every single one of you for making this community great 💙 --------------------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com #ethereum #web3 #blockchain #eth

Transcript

foreign [Applause] [Music] so I'm gonna be talking about um how to integrate the tower Oracle into your project um and it's just going to be a very practical simple uh demo of how to integrate the Oracle into your contracts and how to actually get some data on chain um so first of all the teller Oracle is a permissionless flexible Oracle that depends on a network of staked data providers um so anyone can come in and provide and stake some tokens and provide data and then anyone else can come in and dispute that data so you will see some more context on how that works as we work through the demo um so let's look at an example of a um a user contract so first of all you would want to install the teller user Library called using teller um and you can just install that with npm install using teller and I already have that installed here and so you can see that that will install a um a contract which contains lots of different data getters so you can see it has many ways of retrieving data and the most probably common and most recommended uh function to use is this get data before so this function allows you to input a query ID which is the unique identifier for teller Oracle data and then a time stamp so it will retrieve the last reported Data before that time stamp so you usually input like block dot timestamp minus a buffer period so minus 30 minutes for example so we'll see that in our example and then and using tower there's also many other functions you can look at those in the docs and in on GitHub but we're going to be using the git Data before function from using teller so you just import using teller like so and then in your Constructor you'll have to input the tower Oracle address and so you can find the addresses that are deployed on different networks in our documents or in your test you can just deploy your own test Oracle environment called the playground and you can find that on our GitHub or in our Docs um so like I said all data in the teller Oracle is organized under a unique identifier called a query ID and so you generate that query ID from query data so that is what all of this stuff we see here is is generating um so we have a query a query type and in this case we're using the numeric API response so that's a query type that we have in particular for hackathons so that will just depend on a single API source which is not recommended for production depending on a single API Source but for hackathons it is fine so you can easily get up and running with your custom data your specific data that you want in your hackathon um so this numeric API response it depends on two arguments a URL and then some some arguments from the URL that we will use to extract the specific piece of data from the API response and that is what is going to be reported on chain and it will be converted to an integer or a un256. um so so we have this one read value function in this demo contract which will be it'll be used to go retrieve our specific data from the oracle um so this is how we actually form that query data from the arguments that we set up and then we hash that query data for our query ID and then finally we will be using that query ID we've generated input that into the get data before function to actually retrieve our data and then also you can see that we input the other necessary argument a time stamp and in this demo we're using blocked a timestamp minus 5 Seconds which is definitely not recommended in production because the way the teller Oracle works is that again anyone can stake and provide data and then anyone else can come in and dispute that data so you want to give a buffer period for people to Monitor and decide to actually dispute data so it's best practice to build in a buffer period it's hard to say exactly uh what amount of time amount of time should be used it just depends on how much value is at staked in your protocol um and the subjectivity of the data that's being provided um so but in this demo we're just going to use five seconds because we are going to to try to actually get some data reported on chain and immediately use it um and then so this get data before function it will return a value and uh and all data provided as reported to the teller Oracle is in bytes form so it can really represent you know any type of data it can represent many pieces of data at once so our data providers go fetch data encode it into bytes and then you can decode it in your contract as needed and then this function also returns a timestamp which is the timestamp at which the data was reported on chain and then you can see that this function decodes the data in this case for this numeric API response it is a single uint 256 value so that's what we decode there we also return the timestamp and just for demo purposes we then will show how we can just retrieve the data and save it into your contract um and you can see that we check whether the time stamp is greater than zero so if you get a time stamp of zero that means that no data was retrieved so you should not act as if data was in fact retrieved so that is our simple example contract and let's see now we I uh we can see that it is it has already been deployed on chain um so now we will try to submit a tip or a reward um so that is that is the way that data is actually requested with teller um you request data using the unique identifier the query ID and you provide an incentive for someone to come in and and provide that data so then they will actually get paid so we are going to submit a tip to Mumbai test net using a tipping script [Music] and see if I remember the parameters um all right so we are going to enter a tip amount this will be one test trb on Mumbai and we want to build our query data which is the type is numeric API response which has two arguments two strings and then our arguments in this case I'll grab from our contract first the URL and then the arguments from the URL okay hopefully this works so our script is approving a token spend and then it will add the tip to the contract foreign okay so let's see how long it takes for this transaction to show up um so yeah what we're looking at here is our auto pay contract that's where the tips happen um nice okay so it shows up and now we should soon see a data report show up in the Oracle contract here um because we have some people running data providers watching for tips for this hackathon okay looks like something was reported just a couple seconds ago and let's see on our data feed looks like um looks like some data was provided that was our query type that we expected and 51 was the value that we expected as well um so there you can see just the whole flow of integrating [Music] the teller Oracle into your contracts and then I hope you can understand how you are actually requesting and incentivizing your data that you want um and we can quickly go see in our deployed contract that we can actually retrieve the value this is an old one and now we see the new one provided um so yeah that is the whole flow of integrating teller and getting data on chain um doing what I just did should in a in a real project in this hackathon should be the qualifications needed for for hopefully getting like a reward in the sackathon from teller um and so also we have I didn't I kind of glossed over I I already have test trb in my wallet um but you do not so um if you need any you can go to Twitter at trb Fawcett and you can see the what you need to input and you can get some test trb for the hackathon um and yeah you can find more info on our website at teller.io and on our Docs docs.teller.io

Automatic transcript — names and jargon may be misspelled.