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

Loading player…

UMA 🛠 Building with the Optimistic Oracle

ETHGlobalSun, Oct 9, 2022, 12:00 AM

Welcome John Shutt from UMA for a workshop titled "Building with the Optimistic Oracle". ETHOnline is our biggest event of the year! Collaborate with thousands of developers and creatives from around the world and win over $300k+ in prizes! We're bringing in 30+ of the biggest teams in web3 to give you access like never before. Learn from ecosystem leaders and build your biggest ideas as the merge nears reality. The future of Ethereum is being written right now, and it's time to make your mark. --------------------------------------------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com #ethereum #eth #blockchain #crypto

Transcript

[Applause] [Music] all right good morning good afternoon good evening depending on where you're calling in from uh we have john from uma here doing a workshop on building with the optimistic oracle if you have any questions questions can go in the zoom chat and john will be more than happy to answer them and with that being said i i'll pass the mic off to john hey everybody thanks for joining us um i'm going to be giving a demo on how you can do an integration with uma's optimistic oracle i'm not sure how much you all have read before joining the call but the basic idea and premise of uma is that it is an optimistic oracle for getting any kind of verifiable data to your smart contracts so you're able to get a lot of things beyond prices you can get just questions about the state of the real world you can get cross chain information you can do off chain calculations and you can build entire protocols on top of uma like the across protocol which you might have used for cross chain bridging that uses uma under the hood for verifying that relays are done correctly um so i want to show like how easy it is to actually do this and we're going to do that by answering a yes or no question on gurley with a test net version of our oracle and kind of walk you through the steps let me share my screen all right so the first place you can go is just go to uma.xyz or umaproject.org and then go to our docs and this will take you here if you go to developers getting started this is going to be our quick quick start tutorial and the idea here is that we're going to ask a yes or no question and this isn't going to be based on a particular data source it's just going to be about um an actual thing that happened in the world so we'll ask a yes or no question uh did the temperature on the 25th of july 2022 in new york city exceed 90 degrees fahrenheit you'll answer one for yes with 18 decimal places so like way and zero for no and then after submitting the request you're going to propose a solution through the optimistic oracle's ui which is a pretty common way to deal with yes or no questions and this will hopefully get you started with some initial code that you can take a look at and play around with so i'll exit out of some stuff here and just show the actual flow that you would go to so you click this link it's going to take you to an example contract and remix and in this case i'm already logged in and gurley um i've got some girly eth this is all kind of preparatory stuff that you would need to do for this to work and then you go in here and the code is in this oo getting started dot sol contract and it's a very simple contract it's under 50 lines really easy to read and understand and we're just going to deploy this contract on gurley you can see the little updates down here i'm not sure if everybody's used remix before but we just try to make it as easy as possible so you don't have to set up any command line tools to just play around with uma and see the life cycle of a request a proposal and a settlement of some piece of data so we do have a deployed contract i think this one yeah okay so this one was actually just deployed so i tried to get the settled price in this case or the settled data and it can't be called yet so what we're actually going to do here is we are going to request the price let me exit out of this and reconnect sorry for technical difficulties i went through and did this a couple of times and it might be confusing remix going through here it compiles it and then we can deploy great no instances yet let's deploy to oh you know what i did i deployed to a remix vm i didn't deploy to gurley so you select your injected provider on metamask and now we're going to actually deploy to the gurley test net confirm that if you want you can watch ether scan see when this is going to go through should only take a few seconds and then we'll get an update here once it's done and i am going to go through all this code after the walkthrough and kind of show what's actually happening for each of these steps but just want to show the ui first so it's confirmed there probably take a second more for a remix to pick it up with whatever node they're watching and now that it's deployed you can actually interact with it through remix so we're going to call this request price function which is down here and this is going to request a price from uma's oracle in this case we're not actually requesting a price we're requesting a piece of data we're asking for an answer for the question about the temperature uh in manhattan on july 25th confirm that as always a lot of the demo is just waiting for blocks to finalize there we go cool so we requested the price and where you could actually go to propose a response to the price is in uma's optimistic oracle ui so we can see a new request right here and core to the way that uma works is that anybody can propose an answer to any question and anybody can dispute that answer so it's a fully permissionless system that only relies on one proposer disputer being online and honest so you're not relying on an off chain node network reaching consensus and then pushing some piece of data on chain you're not relying on some validator network you're just relying on one person knowing the answer and you might know the answer yourself and you can just go and propose it and you still have uma's economic guarantees behind it because you post a bond with your proposal and anybody who disputes your proposal uh can claim a portion of that bond um so we have people basically watching 24 7 that are pretty competitive to try to propose and dispute faster than others so in this case the correct answer is zero or no it did not rise above that price you can see all the details here if you were looking at this in real life you might want to look at the umip which defines how you answer this particular type of question because there are a lot of different types of questions you can ask the oracle and each have a different methodology let me take a look at the chats oh yeah i see em pointed that out that i deployed to the remix vm um okay so let's submit this proposal so same kind of thing just waiting for that proposal to go through just pending i always watch on ether scan like it's going to speed it up or something girly's busy today all right so that's indexing should be there in a second oh there we go um so you can see the time remaining so i guess this actually did get finalized about uh 25 seconds ago or something each proposal has a challenge window where somebody can come in and dispute and since this is a test contract the challenge window is set to just 30 seconds and we can actually see that in the code when you set it here so when you're requesting the price you're setting a custom liveness for it so you're saying we just want 30 seconds because it's a test it doesn't really matter and during that window anybody can dispute it typically what you would actually see is something more like two hours or if you have a really complex question where it's hard to tell uh whether you should dispute or not you might want to set that to a longer time period so there are some complex dow governance type things where that might apply uh but two hours is pretty typical you can make it longer shorter depending on your actual use case so now that we've passed the challenge window nobody's disputed this answer can be settled the fact that nobody disputed means that nobody actually disagrees with the answer we don't have to go to an on-chain vote about what the answer is so we can just go in here and settle the request and you can do this also directly to the oracle contract in this case this contract has a settlement function built in here just for convenience and while that's going through i can just kind of like show how simple that is it's really just kind of going to the optimistic oracle this is the you know deployed contract here and calling the settle function and they're settling a particular request so this is the requester it's this contract asking the question the identifier yes or no query the time it was asked sometimes this is important for instance if you are asking what's the price of eth in general you can ask that and then just based on the request time you'll get the current price of eth and then the ancillary data which in this case is really important because it's where the question actually exists that you're going to look at so that went through and we should be all settled and that means that we should be able to now get the settled price and it's zero um so that is a value that you can then use uh if this was a prediction market for instance you might use this to settle a bunch of bets about what the temperature is going to be in manhattan um or it could be something around um you know uh like you're running some entity on the electrical grid and it's important what the temperature is because you need to offset your risk because you're gonna have to run really hard or you're gonna have to spend more on electricity or something all kinds of advanced use cases uh but what's really key here is that it's super flexible this is like a weird specific piece of data it's really not practical to set up a node network for just the temperature in manhattan to constantly tell you what the temperature in manhattan is but if you just need to ask like once or twice or a couple of times it's pretty easy to use um and you can ask any kind of arbitrary question where you can go and find the answer in this case if you want to check you can look at like weather records and you can see that it definitely didn't exceed that temperature take a look at the chat what if there's a bunch of people that want to choose a wrong answer so that's a really good question so what happens there is there is an economic incentive to dispute an incorrect answer and it gets escalated to what we call the dvm and that's basically the voting system it's the data verification mechanism where all of the uma token holders go and analyze the situation and they post a secret commitment of their vote of what the correct answer is on chain and there's a 24-hour period where they can do that and then there's a 24-hour period where they can reveal their votes which would be great to automate but we haven't figured out a good way to do that yet while still maintaining the vote secrecy so you can't just copy whatever the majority answer is whatever the majority answer is at the end of that that's taken as the shelling point uh answer and that shelling point is taken as the truth um there isn't really a good incentive to give an answer that's incorrect because you don't think other people are going to vote that way and under the current system you don't get any voting rewards if you don't vote with the majority with what's ultimately taken as the correct answer and because of the bonding mechanism for the proposers and the disputers this kind of voting system to resolve answers is uh pretty rarely activated what incentives are there to answering at all what if you never receive a response to your proposal integration dow engagement as one of its biggest hurdles into an oracle seems risky ooh lots of questions let me take the first one first uh so the the incentive for answering um so proposers can be given a reward uh so in some cases there's an inherent incentive like if you're settling an insurance contract there are people that are getting paid out on that insurance for smart contract risk for instance um you might need not need to attach a proposal reward for that because you don't need a third party somebody has an economic reason to go in there for other things like for poly market for instance they tack on a 50 reward or 50 usdc reward for each question that they ask um so that's for the proposers and then the proposer has to post a big bond with it too that's where the disputer's incentive comes from because they'll get a cut of that proposer's bond if they dispute successfully and then for voting uh newly minted uma tokens are rewarded to people that vote correctly and if you vote incorrectly you don't get anything if you don't vote at all you don't get anything and we have some new versions of the contracts that are coming out not too long from now that involve more staking and kind of advanced mechanisms for you know potentially slashing people that got the vote incorrectly we have pretty high participation i'm not sure exactly like what the numbers are but it's fairly high in terms of the tokens in circulation because if you don't participate in voting you're effectively getting inflationary pressure on the tokens that are just sitting in your wallet so i don't actually recommend people just buy umo to sit on it it's meant to be used otherwise it is going to get inflated but if you do participate and vote you are getting rewarded for that and that kind of drives that engagement uh the next question from devon jackson what happens if a question goes unanswered for a long time also is there a point at which a question is considered finished um that is a really good question uh if it goes unanswered for a long time somebody could come in later and answer it you could add some kind of expiration aspect to your contract that's asking the question uh so if you have something where you do want an expiration date um you could kind of build that in and then when you do receive an answer you could just say like we're throwing it away it took too long to get that answer and it really depends on your use case whether you want to build something like that in or not how is it protected from people spamming disputes to delay answers that's a really good question the disputer also posts a bond and they will lose 100 of that to the proposer if they're just arbitrarily disputing but i think that this might be more focused around the voting rewards aspect where if you hold a huge number of uma tokens you might have an incentive to try to spam votes into the system um in order to just generate and farm rewards for yourself uh we have a final fee that's attached to that too so that final fee goes to the uma store contract so it's not really meant as like a revenue generator it's meant as an anti-spam mechanism where the cost of that fee should offset most people uh in terms of their uma holdings where it's going to be greater than what they would earn from voting rewards and there are some people that or entities i don't really know that have like a larger amount but they don't spam the system and if they did try to spam the system uh the dow could vote to basically increase that final fee anyway um to stop that from happening but generally if people have some large amount of uma like that uh they are pretty aligned with the network and aren't trying to spam it but we would keep an eye on that and change things i will note also that in the new contracts it's uh it's i don't know how much i'm spoiling or how much i'm supposed to say so there is like a better solution to this where it's not really tied to the number of votes that happen and that kind of removes the incentives to spam at all but i don't want to spoil that because that's like a little bit away from being released but if you look at our open zeppelin audits it has been audited it's not like super secret it's just not like something we talk about a lot yet because it's not deployed yet uh could you share any use case which can be integrated into dapps for better understanding yes so we have prediction markets we have insurance we have cross chain bridging with a cross protocol we have a really interesting use case around kpi options where it's a token that has a variable payout based on real world events so for instance if you wanted to do an airdrop to some users to incentivize increasing tvl in your protocol you could airdrop them a kpi option token that's backed by your token that's going to pay out more or less of your token depending on whether that kpi has hit over some time period so you can get a lot more targeted than just like spray and pray just spread a bunch of tokens around and hope that people want the same things that you want and don't just dump automatically um so from barath uma token holders make the final decision on settling disputes how do you become an uma token holder uh it's you know it's for sale pretty much everywhere um i would recommend just buying it on chain from like una swap or sushi swap or something um because you're going to need it on chain to vote so if you buy uma tokens on coinbase i'm not saying that's a bad idea but if you keep them on coinbase you're not going to benefit from the voting rewards which right now are about like 30 40 and i think that'll probably turn into a fixed issuance rate in the future uh rather than variable based on the number of votes but that's great if you're voting uh not so great if you're not voting so if you just buy the tokens um you know hopefully the price goes up anyway but you're really not utilizing it for what it's meant for we want to draw all those tokens on chain we want all those tokens being used for voting and it is in your best interest because otherwise you aren't getting those rewards and other people are so now there's more uma tokens that are being created uh that you don't take a part in because you're not participating in the voting system um so from tally are disputed values readable by smart contracts uh sorry might have missed this uh yes um yes they are uh also you can bacon call callbacks too so this isn't really shown in the example contract but if you wanted a callback when a proposal comes in for a particular request you could bake that into your contract it'll automatically pull that and you could also do the same thing for uh disputes or for settlement um so you can kind of have complex flows where you might have payouts that are triggered once the settlement comes in and i'll do kind of a quick walkthrough of the actual code here um to kind of give a better idea so this is a really simple contract it's mostly comments um but we're going to create an interface here or like an instance to look at for the optimistic oracle in this case it's pulling in the optimistic oracle that's on gurley so this hard-coded address for our v2 contract we're setting an identifier and this is basically uh 30 seconds really enough to make sure it would have been disputed no absolutely not not in real life this is only for demos um the the default is typically two hours um but you can go even longer than that and we do recommend that if you have um some kind of complex question or if you have some very large amount of money that is at stake um and then in some cases uh well most cases two hours is actually fine especially if you're able to automate uh the review of proposals and disputes to come in which is what a cross protocol does um where that's yeah 30 seconds because if it was a if it was our normal dispute window we'd be still waiting for like another hour and uh 50 minutes um but this identifier uh so this is just like the type of question you're asking in this case it's a really simple question but it's also really interesting because it's natural language there are humans in the loop in this case so one advantage of this style of oracle is that you can frame a question in a way that a reasonable human being could read it and they could give an answer and they could give an accurate answer and you're not going to have those situations where uh the computer is kind of just stupid in some way where you do have this automated system it's maybe bot driven it's you know something but it does something that doesn't actually match the intention of what you're trying to do uh so you can actually ask a question in plain language and receive an answer and specify various like qualifiers of like what types of answers you're looking for based on what your contract is expecting there's a lot of comments to that effect here request price is probably the most complex function in here but it's still really not that complex at all it's really just setting the parameters for a particular request so here we're setting the request time to be the current block time it doesn't really matter what the request time is in this case because it's asking about some event in the past from ivan what are the types of answers that can be accepted can be configured by the contract can the answer be some complex structure so the answer is going to be some numerical value but the contracts can configure like what they're the the type of question is really kind of where you would put the complexity so for instance um a cross is asking a pretty sophisticated question about like whether all of the relays in a particular bundle and a merkle tree are like accurate and also comprehensive that it captured all the deposits that happened on a particular chain at the time that a root bundle is uh proposed but the answer is yes or no um it's one or zero again in this case um but you can have like a question like what is the price of eth that's not going to be one or zero usually it's going to be some other number so it's numerical values um so that's where i would put the complexity on the question side or you could also bake that into your contract so you can definitely consume an answer from the oracle and then do some additional processing on it and that is something that happens with kpi options because um in that case the answer is often yes or no or it could be some linear value but let's say that you're asking did we hit our tvl target or not and that answer might be yes or no and then based on that you might have some kind of like calculation of like what types of um payout function you want to have for that particular contract sorry if that's very general and vague uh part of the um like the good problem of uma is it is like a very generalized oracle uh so there is a lot that you can do with it um so it's kind of hard to nail down like the limitations on what you can do with it there's a lot that you can kind of cram through there as you can sort of see from your ability to just ask natural language questions and count on this uh you know decentralized human incentivized network to resolve it for you real quick i'll see if there's any more questions that come in but just kind of running through like how this functionally works uh this is the type of token it's that's getting posted as a bond um so gurley west in this case so that's what the proposers and disputers are gonna have to post um if there are any disputers the reward in this case it's zero because like who cares it's a test net thing um and then it's going to request the price and it's going to set a custom liveness for it and set it to 30 seconds uh settlement we already talked about and get settled price is also basically the same kind of deal you're doing a get request call and you're getting the resolved price uh from the request which is really only going to work uh if it is possible to get a resolved price otherwise you'll get an error message when you call this function so that was the really quick rundown i do hope that like if you look at this you can just start tweaking this and deploy other contracts to gurley and you can go here it's just testnet.oracle.umaproject.

org so you can test out the full flow with your own like actual questions or your own integrations and this is a really easy starting point literally it takes a couple of minutes to just do the whole floor yourself get a feel for it if you think it would be useful to your project we'd love to help you out on integrating it you know we can provide a lot of hands-on assistance especially for complex integrations because there is so much you can build with it and we're interested in seeing out of hackathons in particular um the more advanced and interesting uh use cases and then we can also help you out with integrations for things like you know covered call options or success tokens or kpi options like all of these things that use some of our homegrown products uh or interesting integrations with across as well i mean there's like a whole range of things that you could do um but yeah we'd just love to like help you walk through it and make sure that um you are using the oracle to whatever way helps your project um one other thing just pitching it out there i don't feel like we have enough people that are using the oracle for off chain calculation um so keep that in mind like that's something that is uh really verifiable um by this kind of oracle system and it would save you a ton on gas it might open up opportunities i know there were people in the past i'm not sure like where they're at with it now they were doing things like volatility calculations for d5 which are just not practical to do on chain but lots of stuff like that uh cross chain stuff is also super interesting like the oracle can see what's going on on solana and you don't have to post any messages on solana at all it's just you know anybody could go and verify what's happening on solana so if you want to like give an airdrop on aetherium to um you know somebody that's had has some solana nfts and have identified their ethereum address like elsewhere you could do that and you could enforce that with the oracle just like random stuff there's so many things so please contact me i'm also at jdshutt on twitter i'm pretty active in responding to dms and just love talking through new integration ideas too so please share oh sorry is this was the sound okay for other people i saw a siren nava uh that it was ridiculously quiet hopefully it wasn't okay all right well i guess that's everything thank you so much john that was super enlightening um and really cool workshop that you did there um yeah i think some people are asking for your oh you already answered great cool um yeah well thank you so much for taking the time to do this for us and thank you to the rest of you for tuning in to the umo workshop today um uma will be available on for support over the next month on discord or anything else that uh john had mentioned and with that being said we also have another workshop on scaffold eth by austin from the ethereum foundation as well as kevin jones if you're interested um please tune in to that as well and uh but i i hope everyone has a great rest of your day thanks all thanks for having me bye

Automatic transcript — names and jargon may be misspelled.