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

Loading player…

Chronicle 🛠️ How to Integrate Chronicle Oracles into your Protocols

ETHGlobalWed, Oct 9, 2024, 12:00 AM

Join Chronicle for an introduction workshop in preparation for ETHGlobal Istanbul! From November 17-19 2023, ETHGlobal is welcoming builders from around the globe to help shape the future of Ethereum at ETHGlobal Istanbul. $500,000 USD in prizes are up for grabs at the prestige ICC Istanbul Congress Center... you're not going to want to miss this! ----------------- Follow us: https://x.com/ETHGlobal?s=20 Check us out: https://ethglobal.com/ Email us at: hello@ethglobal.com

Transcript

[Music] GM fellow hackers I'm mer plant one of the engineers from Chronicle and in this video we're going to check out how you can integrate our overs into your protocol um this will be a Hands-On presentation so we're actually going to develop a small smart contract that reads from multiple orod and uh we'll deploy this to a test net and see whether everything works out I very much hope so if this sounds good then cool let's start and figure out how you can integrate chronical oracles into your protocol for that first we go to docs. chronical lfs.org uh and yeah you see here is our chronica protocol docs coste efficient verifiable data you know what we're doing and let's dive directly into the documentation you see it's still a little bit empty everything work in progress we are working hard to fill this up with a lot more useful information but here already some information from hackathons that we're going to use now to show how you can integrate and use our Orit one preup just about our new Oracle version scribe uh scribe is our new Oracle version it um is 60% cheaper compared to our previous version and also compared to the competitors on the market and even 80% like it has 80% savings compared to chain link so updating the oracle is 80% sa cheaper in our case than in chain Link's case on the long one well this has to mean something um scribe is in that way quite interesting if you are like really into the Technic technicalities in that it uses schnor multi signatures we are the first one who were able to use schnor signatures on the ebm in a gas efficient enough way and multi signatures enable one interesting feature that um other Oracle providers still have to figure out because it gives you a more Hazard and that is if we go to Chronicle protocol scribe so to the to the um documentation and check out the document uh to the repository and che check out the documentation and go to benchmarks then we see here two different graphs one of them looks linear or is linear and the other one looks constant and is nearly constant and and um I just want to quickly get into this moral hazard that you have as a normal Oracle provider and that is generally the more signatures you have the more people are signing a piece of data the more secure it is there are of course like it's not as simple as that like if you yourself sign the data five times it does not make it more secure but if different people different entities in the network sign the data the more the better the more the more secure and the problem is however the more signatures you have the it also costs a lot more to do this signature verification on chain is basically a linear increase because you have to add each signature to the call data to the transaction and each signature needs to ver be verified on chain it's basically a simple for Loop for every signature verify signature and this means that Oracle providers are generally not actually incentivized to increase their security because it means they also increase with that the cost for updating the Oracle so there are basically two different ways in how Oracle providers can do this either they don't increase their security and run with like a number of signatures like seven signatures which is really not that much or they have the great idea of moving the Oracle update to the user and basically that you pay for that um by having the oracle update inside of your transaction both of them are not really the end solution because in both of them the protocol is not really incentivized to increase their security um in a with reasonable uh gas costs and Scribe is the first Oracle which managed to get rid of this moral hazard as you can see here we can increase our signatures to 100 signatures Which is far more than any Oracle provider can currently dream of um and we increase our costs compared to five signatures by 2K of gas so this is practically this means it's constant practically it's constant and we get rid of the moral hazard of do we want to increase the the security or do we want to pay less to or the update the Oracle we can always increase the security we pay the same to update the Oracle so this is something really interesting for um yeah if if you're technical enough if you're uh into cryptography or into ebm lowlevel program in this is something interesting for you but that's not why we're here sorry got a little bit SN sniped we're going now back into how we can use our orles so let's go into first the interface which kind of interface do you need to read what is the interface uh what is the function to uh to read the Oracle and all of this the iconical interface is defined in the so-called chronical standard repository this is a repository that we use in nearly every project and it defines the iconical interface and if we go into it we see the iconic interface is pretty short this is on purpose it's uh special made so that it's very hard to misuse and that it's as easy as possible to use and yeah you will probably only need this two functions most of the time generally always the read function it returns to the current value of the Oracle or the read with age function it returns to the current value and the age of this value so if you for example say you only use a value that's you know at most this minutes old or hours old uh you can add this check inside of your protocol and use the read with h function to receive um the time stamp of the Valu um which contract are we going to use now so we are deployed on a lot of different contract on a lot of different networks stage test networks and production networks um I think the documentation currently has seia and ZK evm okay let's go with seoa because this is I guess the most used uh test network and to be honest I already set up a wallet for that now so um if we see here for the seoa network we see all the orles that we have here we have yeah all the usual ones maybe some unusual ones like s die and D which is quite interesting s is this die version that URS interest continuously so here you can basically um compute how much interest did s die since it it's Inception increase already acur already an interest compared to die and we also have for example ebta which is an uh ETF uh like US Treasury bonds ETF from Black Rock so also a little bit of real asset um data to play around for you um yeah and of course all the usual one e USD RUSD btcusd um okay now we know how we can read the Oracle interface now there's one more thing that we need to talk about and this is the uh well the kissing um let's have this kind of talk so generally Oracle providers um always have some kind of whitelisting mechanism in front of the oracles because um well customer someone who uses the Oracle sooner or later needs to pay or provider is a normal business normal uh yeah a normal business that has real expenses we need to update the Ole continuously this costs a lot of gas so there needs to be some kind of wh listing mechanism and in our case the wh listing mechanism is called um toall so we expect a toall um but because we are so focused on our customer relationship we turn this uh action of adding you to the white list ures so as soon as you become our customer the first thing we do is give you a kiss and if you decide not to be our customer anymore we diss you this means we remove you from the white list um these are the small jokes the engineers like to build into the contracts um anyway on Main net of course only we can kiss you only we can add and remove people from the white list on every production Network on test Nets you can do this yourself just so that you can for what we are doing now integrate our integrate us and and play around with our our kids as much as possible and for this we're going to check out the self kisser repo and the self kisser is a really simple contract which just allows you to kiss yourself on every contract on the chain and um yeah we see already there's some documentation about management and here we can see that we can self Kiss an address why running this lines of code here and yeah so let's do this so first of all I already get clone the sa Kissa repository and I created another repository uh the called Oracle reader this is just a simple contract which has a storage variable one Oracle chronical Oracle here we have the interface the I Chronicle interface that I just copied from The Chronicle standards repository uh and it has a simple read function so we basically just read um the Oracle one time and yeah you can call the function the Oracle gets read and um Returns the value and the age here's a small script included to deploy the contract um this Oracle that we're going to read adjust randomly choose now eusd so this is the eusd address that I received from this list here we can also use a different one um and we are going to deploy it via this lines of code here for that of course we need to have some kind of um wallet so let's check out how can we create a wet um generally I would heavily uh put to your heart to check out Foundry is a blazing fast portable a modular toolkit Forum application development with menw man that really breaks a tongue but okay if you're on a Linux Unix machine you can just run this line of code here um it will install your Foundry if you're on the Windows machine just just head to the book into the installation and here you find all necessary information there's also really supportive telegram group where you can ask further questions if the documentation does not help you enough and um yeah I would heavily uh yeah check it out it's worth it um Foundry is a very good tool and it gives you one of the many tools that it gives you is cast and cast itself is um is a kind Swiss army knife for everything eum and evm related and why I'm showing to you now is because we're going to create a new wallet so we go in with cast wallet and then new and we see okay cool we created a new private key this is the associated address um so if you now got this address you can start playing around for um for the purpose of this or this tutorial one thing you'll need is you need to have eum on the net on the network on seoa for this you need to go to some uh faucet I have linked here a fewer in seoa faucet so um if you have an INF or Alchemy account you can get here like 0.5 e every 24 hours to play around with um another thing that we also need is an RPC node for RPC nodes generally you can check out chain list.org and uh you can search here for the chain in this case Thea and you see here a lot of different RP C notes provided uh that are for free okay so now we got an contract that we can use to test our oracles I set up a wallet already with a private key and um an address and I already got some e and I already got some Ease on that address so we can start playing around now and yeah first thing we do is maybe deploy this contract so while deploying contract we should be able to read the Oracle so we need to have some kind of RPC Ur let's see whether we find a nice RPC Ur in the chain list.

org here let's take this one why not okay and then we need to have a private key then we need to have our private key and let's one it and we will deploy a conflict at this address send the transaction it's waiting now for the recite so that the transaction is actually finalized um wait the transaction was finalized so the contract creation seems to have worked out if we go here ether scan is not yet updated I think Isa scan Isa scan took a moment okay everything worked out so we created a new contract it's at this address um 52 this is also the address was printed here 52 88c 52 88c so this is our uh small little Oracle reader which will read from the eusd Chronicle Oracle via this function call um now we got a small problem because this Oracle this contract is not yet allowed to read from our Oracle we need to kiss the Oracle before so we go into the self kisser repository docs management and here we see how we can for every function that the that the that the self contract has we um get documentation how we can call it generally we need to have one. end file so environment variable file this is just to give in all our environment variables so we need to have an RPC node let's copy this RPC node here we need to have our private key we need to define the self kisser instance so where is it actually deployed good good question actually it's deployed at this address so we can go here perfect then um we want to self kiss ourself so which Oracle do we want to be kissed on the Oracle that we wanted to be kissed on was the eusd Oracle so this one and who should be kissed on that Oracle so who should have access to this Oracle this was the contract that we just created so this one okay so this should work out if we now copy this command run Swiss do environment um we in the different repositor so we have to go into the C you see okay we self kissed on that Oracle this address it's waiting for the resite send the transaction already and it's sent okay and it's done cool so now we should be able to um see this on the self kisser here get chain link seems to be is skin seems to be a bit slow here from time to time now we got it so we see here we got a two events toall granted this is from The Chronicle Oracle itself which says AOL this this address here now has access to um to the Oracle and this event basically the similar event was also emitted by the self kisser contract here again and that's it now we are able to read from the contract from this Oracle reader contract and let's try to do this by just changing this one function here to something that we just say okay we're going to read the Oracle so we say um we got an oracle reader which is our reader and the reader is list at some specific address and the address was this one here this and now we can just say okay let's instantiate uh the reader the Oracle reader that's this is the address we instantiated as an oracle reader we call the read function the read function should return us some value in some age and if we run this now we get back to the Oracle reader we have to run again this long script with the RPC URL in this case this [Music] one of course we have a typo otherwise it wouldn't be fun right and we see okay we got here value and uh we got here value and an age as you may see ether is definitely not worth that many US dollar um that would be a day at which I would not work anymore for sure so what is wrong here how can this be uh the thing is that all our orits provide the data in 18 decimals so we have to basically get rid of 18 decimals here we can do this manually 1 2 3 4 5 6 7even but that's a little bit to arrone we can also use cast with while doing it so if we check here um we see we have here different functions to uh to do type conversion so in this case we need the from y function because y like ether uses 18 decim e has an 18 deci with Y so we have the same thing so we copy this value here and say cast from why this part then we see okay e is worth 1,5 570 and this is not off to this what's here currently so yeah the Oracle is $35 off at the moment this is also just a staging Oracle we don't update them that often but it seems to work all out nice so yeah the Oracle the contract that we deployed is able to read our Oracle the value itself seems to be correct we also got a time stamp we know how old the value is and um all of this yeah I hope that was not too complicated I hope you uh figure it out if you have more questions regarding for example skripe we get here like e magician post the skripe dogs along Twitter thread in which we go into more detail for other things um here is more documentation and more information about this and if you got any questions please join our Discord um hit me up I'm worker plan uh just write something in the Discord we are here to help and we wish you all a lot of success and luck integrating all our Goods

Automatic transcript — names and jargon may be misspelled.