Gnosis Chain 🛠️ Building on Gnosis Chain: Using real world information with Tellor - Nicholas Fett
ETHGlobal·Mon, Oct 9, 2023, 12:00 AM
Speaker
Join Nicholas Fett from Tellor for a workshop titled "Building on Gnosis Chain: Using real world information with Tellor". Thank you to everyone who joined us for ETHGlobal Lisbon! After being away from Europe for almost a year, we've decided to bring the heat and excitement back to the stunning historic streets of Lisbon! All over the world, hundreds of thousands of developers, users, hobbyists, creators, artists, and market makers spend their days and nights thinking, building, talking about Ethereum because we are... excited. We're excited by the idea that Ethereum can change things. This May, we invited you to come learn what all the talk is about. We were joined by the leading teams in the ecosystem such as Polygon, Metamask, Aave, 1inch and Gnosis Chain who have a number of prizes up for grabs! This event is focused on building a new product/protocol, learning at the summits through talks and workshops, and giving opportunities to gain valuable feedback from ecosystem champions at the beautiful Convento do Beato. Find your future team at our Hacker Café and create even more meaningful connections while engaging with some of the most notable speakers in the industry at Pragma Lisbon. At ETHGlobal Lisbon you'll have the support of a huge community of experts, mentors, sponsors, developer advocates, and other community members who want to help you build something awesome. ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com
Transcript
foreign [Music] hey guys my name is Nick Fett I'm one of the founders of teller and I'm here on behalf of gnosis chain so figure out how to click here um before I get into just what teller is and I thought I'd at least I have to at least say the sponsor Google me here in one knows this chain so for those of you that don't know about noses chain noses chain is an alternative L1 so similar to ethereum it is an evm and it's got the works so it's got a bridge explorers amms all the wallets aboard and I know you guys are like well why the hell do we need another L1 or another another chain but the truth of the matter is if you actually look at all the l2s or anything that's actually cheap they're all like really shitty there's like a multi-sig or a centralized sequencer or an admin key and they can like rug you at any point so if you want to actually build a censorship resistant application come to gnosis chain we'll we'll love you over there so okay on to teller so uh kind of how how I got started with teller back in back in 2017 I was trying to build a derivatives protocol I was trying to do where you could like do you could lock Ethan do a smart contract then you would have long and short tokens that represented like long Bitcoin short Bitcoin and I know that this was like novel back in 2017 and um anyway we got an ethereum Foundation Grant to to start building that and you quickly ran into the problem of okay well who gets to say what the price of Bitcoin is and the problem is is that smart contracts can't read outside information so due to the fact that you have to be able to like replay it for all of time you know if you were reading an API if you know somebody a year down the road tried to run that smart contract function they would call the API and it would get a different result so things would break so you actually everything needs to be an input and this input is What's called the Oracle so who gets to do that is is a big problem for things obviously such as price feeds when building derivatives and then other things you know Bridget is other pieces which I'll kind of get into so you know what are the oracles so back back in 2017 there actually was an oracle live on ethereum this was if you guys remember Oracle eyes this was Thomas bertani and he ran Oracle eyes and he you he would like pay him a quarter or 50 cents and he and he would return the result of your API call that was literally the the Oracle that people were going live with in production back then you know this was pre-chain link for everyone and that's obviously a really really bad Oracle the reason is is that if he died or if he decided to change the value or rug you you would have no recourse um so you know you can go beyond that and it's okay well well how could we make that a little bit better I don't know like we trusted Thomas let's trust vitalik and you know we'll trust stunning uh so okay so we'll do a multi-sig and that can also be an Oracle and you know that's like um whenever maker started they were one of the first people with their own kind of custom Oracle and it was basically just a multi-sig they they had you know 14 people and it was a multi-second and it and it worked um you just have to trust assumptions of a multi-sig but it basically you have to kind of rethink about how you're thinking about an Oracle and it's just how do you come to consensus on data and this is sort of the problem because it's you know in in the blockchain world we're really sort of honed to thinking about coming to consensus at like the chain level but then at the app level it's still the same way how do you come to consensus quickly on a piece of data and you obviously can't build a blockchain you know it's like now it's actually possible with Roll-Ups but like building building blockchains on top of blockchains to decentralize it gets it gets really old really fast so we'll kind of go into how we solve that problem and how some of the other people are and how you can use them so what are oracles used for obviously there's there's price feeds um ridges so bridges are orbitals if you have noses chain over here and ethereum over here that they don't know anything about each other you might as well be reading an API from coinbase a bridge basically just reduces the Assumption you have more generalized oracles where you can ask it any question like you know who's kind of like at the bottom prediction markets you know who's the president of the United States who won the Lakers game you can ask it these general questions or you can have very very specific orbitals like what's the block header of Bitcoin next that's still horrible but and you need some way to come to consensus around it other things you know insurance as well um anything off chain anytime they talk about if you hear somebody say like oh we're gonna put real world data on Jane and it's sort of this Meme and the problem is is okay well who's putting the world data on Jane you know that's an oracle problem you probably have some centralized entity that is in charge of saying it went on chain or it went off chain and that's a problem you should maybe use tellers to decentralize that a little bit um but as we can go into building this you know these generalized consensus mechanisms the scalability trilemma it holds for oracles too so if you want this thing to be really really fast uh is probably not going to be very decentralized and it's just a trade-off and so any Whirlpool that you guys see out there that you're thinking about using if they claim like we can you know update your price speed with instant finality every block and you're like there's there's just no way um besides the fact that it would be really really expensive for it that much that at a chain um because you can kind of think of you know if you had the question or you know like who's the president of the United States well what's like a really slow Oracle if you guys remember like uh one of the original oracles out there was auger for for those that you know or like gnosis but back when gnosis was a prediction market and basically what you would do is you would have all these tokens and you you would have like a you would have to ask it a yes question or a note it would have to be a yes no question and then people would stake all their tokens on whether it was going to be a yes answer or a no answer and it would take like a week and that was a that was an Oracle and that was a valid it was a great way to way to do it the obvious trade-off there is it's super super slow so didn't really work for Price feeds so um we we've since come to some better Solutions um which gets me now to how teller actually works um so tell her it's it's kind of a simple Oracle we we really focus on how can we actually be decentralized you know we we came into the space you know if we're building on ethereum if we're building a gnosis chain if we're building on these Networks you're only as decentralized as your least decentralized point so what you want to do is make sure that the Oracle isn't that sort of centralized stroke point so how can we make sure that this is decentralized in the sense that anybody can do it and anybody can validate it and so what the way our Oracle works is you you stake some teller tokens so you grab um like on Main net it's like a few thousand dollars worth of seller tokens not not a crazy amount um and you lock it into a smart contract then somebody else comes and they tip they say hey I'll pay one dollar or probably on ethereum more since the gas is really really expensive I'll pay you one dollar if you submit the price of Bitcoin on chain all of those staked reporters then uh right now they're all like Mev bots on our Network they they race each other to go and submit the price of Bitcoin Unchained you you don't want to use it right away though so this is sort of the caveatsis but that makes it slow is you actually need to validate it because there's no way for the smart contract to intrinsically know that that value is correct once you put it on Jane you can put anything on chain but it's an optimistic Oracle so you put it on chain if nobody disputes it for a period of time then you can use it what is that period of time well that's up to you if you wanna if you want to YOLO it and say you know five minutes okay you can do that if you want to wait 10 minutes 15 minutes we have a mainly usually it's really really fast like a minute for a dispute just because all the other reporters are running these monitors to catch each other and because if you catch it you submit a dispute fee so it's a small fee and then if you win there it gets pulled off the data gets pulled off goes to a two day long vote you can win the guy's whole steak so it's very profitable to to win these disputes and um but yeah and then for the user so the way that we sort of use teller to make it really really fast is if once that data gets pulled off chain you don't have to wait for that result you as the user don't actually care the next person would just throw it on chain and that's who your dollar would go to so it's sort of just the wait period is roughly how long you are going to wait for a dispute um all right and then your smart contract reads the data so now let's kind of get into what are just some best practices whenever doing these orbitals and you know you guys are at a hackathon so I wanted to like try and keep it hackathon focused as far as what can you build with oracles what what are good use cases for a blockchain um the biggest thing and the biggest problem that most people have whenever they're starting to use an orbital is like you'll hear people with very very Niche use cases so it'll be something like uh you know I think there was one guy he wanted to do car insurance on the blockchain car insurance is really really hard and you know like he's like well could there be an oracle that says you know whether or not somebody got an accident well like if you think about it who's that Oracle like who who can actually validate that and and the problem and that's a problem of you want it to be something that everybody can validate because once it's put on chain if you can't go actually see that that person got in a car accident you can't validate it or say anything about the truth of it so there would probably be rampant insurance fraud and this is a problem with most things so you know if you have some calculation that takes really long to run or you know if there's you know the classic the classic example is like what is it like crop insurance in Africa we're going to make on the blockchain um you know if it whether it rains in a certain region this was this was always like one of the one of the old examples that people would do at a hackathon and the problem is always well how do you tell if it rained in a given region you know like is there it's really really hard and it's not necessarily straightforward whereas like the price of Bitcoin we all know you know we know what the price of Bitcoin is it's very very easy to tell if you lied um but that you know on the price of Bitcoin Beast too um there's actually a lot of trade-offs whenever you're even defining the price of Bitcoin so for instance if you're talking about the price of Bitcoin you can have okay well what's if you say what's the price of Bitcoin on coinbase that's a different answer than what's the price of Bitcoin as a median between coinbase bracket and binance and that's actually a different answer than what's the price of Bitcoin if you just answer it and there's actually different trade-offs for each one because the the first one what's the price of Bitcoin and coinbase super super easy to verify um and if you're you're using this D5 protocol for instance it's like a hedging platform you know what exchange you're able to hedge and that and that's super useful for throwing handful tools the downside of course is decentralization you know you know they you know that the person if you want to throw that Oracle feed you just have to go throw the API in coinbase and go go make some big trades on coinbase whereas if you just say okay well what's the price of Bitcoin this is where that subjective data comes in in the middle okay so you know if it's just the price of Bitcoin well maybe there's like a one percent will room in there you know because it's not going to be exactly the same on every exchange so you sort of have to be okay with that wiggle room but um yeah just different different sort of trade-offs you have to think about as you're putting it on we always recommend don't like any any orbitals that's like oh just put in your API and we'll go get it it's like well that's it's a centralized API like you don't want to use that for your Oracle you have to think about how how can you get the data without a centralized API and then you can potentially have a decentralized Oracle in the future so all right I'm going fast because I know we were started a little bit late so Gonna Keep Us on time um this is just the basics um how oracles actually work so there's several different kinds of oracles there's push oracles and pole oracles so a push Oracle is one that will push it directly to your smart contract and Implement an action a poll Oracle is one say like Ching link or or teller where it updates its own smart contract and then you have to run a function and go grab it so there's two different things usually that they're actually converging as time goes on just because um what you can do now is is there's a lot whether it's gelato or the keeper Network or those you can just sort of automate the action once once the polar orbital is ready run some action and push it to your small contract so that's usually best practice now um do we want to look at code more fast maybe a weekend uh yeah we can show you guys how easy it is to kind of look to build an oracle um sorry you guys see that can I zoom in better all right I mean I can zoom in again it's so the way the teller works is it's a generic Oracle and this is what's kind of important that I wanted to show you guys um we have a helper smart contract you can just come so this is sample using teller it's a repo in our ghetto um you just npmi using teller pulls it into your node modules and then you can import it and do sample using teller is using teller makes it easy to to inherit it but the way that teller actually works as far as getting what you want and knowing is it's this uh we call it query data so we we have these data specs for how we Define what what a piece of data is so the spot price data spec what we do is here is we encode the word spot price and then for instance gno USD and that's asking the Oracle for the gnosis US dollar spot price obviously um there's lots and lots of different data specs that we have so you know other ones that we have are like snapshot vote result so you put in a snapshot vote ID and a chain and a contract and and it'll go get you a result of a a snapshot proposal other ones you you can do like evm calls to different chains so you just need to give it a chain a contract address and then call data and it'll return that call to your smart contract but basically and these are ones that we already have but you you can actually come and it's open source so you know like we have these hosted on ipfs you can make your own data specs so if you want to really think about okay what something custom that I would want to do um really the the sky's the limit you know there's there's a lot of different pieces that we've done another another fun one is is we do like cross chain balances so like what we do is we'll return like a Merkel root of all the balances so if you have a token on ethereum and you let's say you want to airdrop over on um polygon to the Token holders of a token on ethereum all you would want to do is you could put like the Merkle root of all of those balances over on ethereum or over on polygon and now people can go and claim and prove that they have that balance and that's a much more efficient method than bridging over all the balances so basically yeah kind of just telling you you can put on whatever you want it's not limited by any type it just returns bytes data so you'll have to decode it at the end but if you want to return very very large strings you can do that and then yeah you just you run once after after you would tip for it or put it on chain yourself you just run git Data before the query ID and then this one this is showing down here the best practice block timestamp minus 15 minutes you're waiting 15 minutes for a dispute making sure that it's it's valid um and then you can update it so that's about as simple as it gets I'll go back to my presentation I know we're they're ending over there so I'm guessing that means I have to end right um and but I wanted to give kind of before before we ended just um I know some people were still looking for ideas or if you wanted ideas these are some of the cool ones that I was hoping people would build whether hopefully I knows this chain or with teller um other ones so things that you could do you could build token Bridges so you know we were just talking about how you can use that evm call but like you could make it a mixer which is what I think people should do so you you could Fork some tornado cache code where there's a proof of a deposit but why don't you just take that proof go put it on another chain all of a sudden you got a mixer and it you could put it on 10 different chains if you put a chain ID in there as well and now you're mixing across chains so some cool ideas you could also I want to see somebody do a brc20 on chain so you could use an oracle to go grab ordinals data from the Bitcoin blockchain you put that stuff tokenize them put them on the ethereum network maybe get some of the Maxis on board um other things uh Bounty programs so we've we've seen people do this with oracles you can use an oracle to bring on how many Twitter followers do you have how many Discord followers does your channel have how much volume does your token have and then you could set up Bounties in a decentralized way like hey I'll claim this I'll get you 500 new Twitter followers the Oracle will bring on the start Twitter followers and the end Twitter followers if you if you bump that number up by 500 you're going to get this bounty you can do something like that with an orbital uh other things that we're working on you you could really go if you wanted to get really uh sort of econ about it you could build like a decentralized CPI so like how would you do that you know that's more of a question for how do you structure okay what data do you put on chain how do you put lots and lots of that on chain and then yeah kind of last same thing like music bounties you can put on Spotify streams you can put on um okay did an artist release a new album something like that lots of different things you can do with an orbital and and hopefully kind of spark your guys interest so anyway here's my contacts um thanks hopefully you guys learned a little something about oracles definitely give me a follow on Twitter uh do I have time for questions or yeah if you guys have a question or two I can answer it we have to yeah so he asked if we have a token we do so you have to stake our token that's that one Tom you know well yeah so he asked like how do you validate like if you're asking for a cross chain information how do you validate that it's not a fork of the chain and that's why it's like optimistic so you would want to wait on it you know like you would be the person could potentially get slashed if they're doing it and and you would have to well yeah it would probably be invalid and we get voted and dispute it but you know you if you were the user so like you would want to wait like it would depend on what value you were bringing over right like if you were if you were doing a token bridge for instance and you're bringing over ten dollars like nobody's gonna Fork your chain over ten dollars like you probably read it relatively quickly but if you're bringing over like 100 million dollars like yeah you're going to want to wait for you know 100 block confirmations make sure that thing's secure so yeah I think that's just general best practice for these Bridges but um all right well thank you everyone
Automatic transcript — names and jargon may be misspelled.
