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

Loading player…

Developing Data-Rich Smart Contracts via Provable by Greg Kapka of Provable Things

ETHGlobalFri, Oct 9, 2020, 12:00 AM

Greg Kapka, the Lead Ethereum Engineer at Provable Things, gives a talk how to develop data-rich smart contracts on ethereum via Provable Things. ETHBoston was an ethereum focused hackathon that took place Sep. 6-8, 2019 at Northwest Building, Harvard Campus. ETHBoston was a hackathon organized by ETHGlobal and a team of hackers, developers and enthusiasts interested in building and creating in the ethereum ecosystem. The ethereum focused hackathon took place for 3 days at Northwest Building, Harvard Campus in Cambridge, MA. For more information visit eth.boston and ethglobal.co

Transcript

[Music] eh small contracts on ethereum I had things who means like external right place because that is what we do I'm gonna read it out and you know read as well we are a security origin dates 2011 centralized applications of connection with Web API we same thing we reliable great to meet smart contracts and the Internet right cool diagram to describe pretty much exactly that and if there were to be no obviously what chain behind computing you can see our eco app probably better in some stats about first I'm gonna go quick so we can get to your we've been on the projects and are available currently on fire from what changed we watch an agnostic interpret service all sorts of places basically anywhere whether it's the mantras where you go so if you are working on a different we are in books as well wearing it but that's not why she did it and so yeah we're pretty no we use a single API to allow your contract to use external base engine and this is pretty much all you need to know in order to users obviously is a very important ellipsis this is all you need and you need agreements here on this laptop to making noises but it just this is my textbook is very very thank you here we go so that one line in pecan flash our pies those that should say provable things I should have paid more attention the API bit is correct but it could be slight bruising actual things experiment guy truly salt whether that imported into the talking about contract you will get access to our entire API to use methods you can use called any URL you like and fire the construction a bit higher to where it says provable understand query so first we inherited is brutal and then we can pull a query to make output as I already spoke and finally on also development environment the kits that they already with triple we're three minutes man we try and get everywhere because like come to miss places like the developers are important I'm going to make it as easy as possible easy so I'm going to show you this which is simple wave easily be truthful so I'm gonna agreement of it is as easy as copying basement okay in fact in our examples repo any of those examples can be dropped straight into remixes copy and paste with truffle we provide the triple box which is a great way to get familiar with the service if you just yeah they're super easy right so and our report there's all those same things for you you pull it down and force them as a smart contract that's an example it pulls down on our API has everything is sorted and more importantly includes one extra special bit and the extra special bit is what we call a very bridge the reason this is extra special is this means that you can leverage our service on any marketing of your choosing whether its private or not so when you're developing tender what you're going to be using the truffle railway and you want to spin up a local chain you don't want to have to you want to use a local packaging quiet revolt which means you can iterate regular tests across them and you should be testing all the time especially so the etherium bridge allows that to happen so you can use our service completely local dev environment and still get the same provable are up reserves which great the if you don't have a look at the triple box is that simple fact this is like I have on it so these three buttons but it is it okay triple spider conception how they edited the back yes it is epic it is actually got a pull from end tampon in as well okay so it's I think it's a different example but the actual back end are even smart contract it's exactly the same as any of our approval ones that you should be exactly the exact same query just give up so if you're interested in developing a small contract specifically wanted just going to do any other for them quick and easy probably quick to go to other box if you want more quality duck but it's probably a bit hard if you just happen to make it's a bit more finished I don't have anything it's really cool so when we followed it the truth watch you can just run the test like this the reason we've said it's the intense straightaway is because if you do that you get to see there to make improvable query whilst you watch it and that's when your local connection that it spins of all the tests and it's you have even now this is important this is whatever episode race through any questions first for HS week let's see it alright this is a completely small contract and that works and is using our API in order to get external data so you can you just copy paste and it's a very important contract with as we're actually trying to find out the temperature here beef Boston so granted you can just go outside but we do it this way so what you are looking at here is the basic query right at the top you have an import statement URL hey URL query and the next parameter is privately the URL that you want alright normally Jason wrapping around it for one second all you can see is we've got a generic URL to a weather I lived on me with last view once you type in that happen to coincide with where we are top right now and we're those two bits of info ie you are L and a request for a URL we have our free will query now the JSON that bit around it simply is an extra bit you don't have to respond to me or L so this is what the jason brackets and then don't make the template is just saying hey Jason so once you have that function set up do you have approval pre-reading to go needs is a callback our standard way beautiful is by the double on the scope and Paul back takes three having in two parameters in this and they are the query ID and a string which will be the results so this callback function is actually what the approval of service calls which is why than a client has a requirement on it check whether the massive summit call in this function is indeed approvable press because you don't want this to be fall fight anybody otherwise anyone can spend whatever days they like you want to send you the data that you've requested provably at that point we're gonna actually look at our result which here and i've actually just passed their other but the part is if any of you familiar with solidity is not a solidity function it isn't for the helper functions we provided the api so when you inherit it at the top it was a whole bunch of helper functions which don't get compiled unless you actually pull them in your contract so it's nice and light in this case it will be passing functions we can used it and when you set and pull into whether the temperature under weight jacket required is very that are equal to that is the result and finally we actually just walk the results that people did see it and I would if I could picture newest remix but what you do is just you all can click the point being this is an entirely the entire thickness is all you need to be like all any API access service if you up make this my contract today I need external data the quickest easiest a prequel way to do it instantly why our approval things it's because you think it's just a very basic but quite durable we mean that we supply would have our API calls while the disagrees which pop cryptographic guarantees and we used various ways by these guarantees but all of the micro-tv ease which if you've been to little talks today you can definitely look some movies now beer is really good actually a TV is a trusted execution environment which is some form of like hardware to legitimize the graphic encryption of stuff happening so SGX Intel SGX is one of them powers and NLCS that notary provides a Android has its own sandbox in between uses attuned to the ledger if you're using ledges and all the various hardware at once they are for spanish-speaking environments and we use all of them to do things and say hey look you asked us to read this this API and we did it by this trusted executed environment and provide a proof to do it that we did it so you get the result back and debrief and you can verify that yourself so you don't have to trust us anymore we don't want to interest us we're very trustworthy but we don't trust in this place we verify and so we provide proofs so that you can verify we have done or rather the video of asked to be done I was doing it's our execution environment and that step I highlighted in orange yellow screen to show you how you would use a proof and aquarium so here is an example this time we're doing something that everybody wants which is getting the price of aetherium in this was in Bitcoin I thought it was in USD but it's not it's a bit but again this is a common thing on the ethereal chain there's no concept all the US dollar popping you all very much look we can find out we have two functions and one following approval query again using URL again using adjacent of this being an approved so we return the ID which is a hash which is unique to your ID which means you can use it to track your IDs in yo string resolved again and now we've got the fights each other free here we're actually using the breech baby we just put in here to show you that we can provide the troops on the key on this one is that conceived by the constructor is how we actually tell the service which proved to be one so in this woman we are saying three bowls of fruit we look and return please which means it's gonna use the under it te e to Fabio carry on then and overturn TV or result plus the proof that it was done that way and you can take that proof and you can go and say that's cool whether it was very touch it is another example and this one is super important which is diesel prices and where's the last time you diesel diesel price I don't even have a never well if you did it's how you do it using approvable again look about bottom function it is simply a variable of smoke we recalling the URL data source and a URL itself this time the passing wrapper around it uses an XML parser so we're talking like it annoys everybody website so that's a different way from the district on the first type of this time we're asking for a TLS a new recruit this is the and more importantly whereas the proof storage this kindness so what net to some means if the talents and proof is massive so it's the same cup of momentum earlier where if you just query in URL you might get a lot of data not string one fit inside before they went to fit inside of born it was too much data and the teamö sentry is the same it's a very big traffic free fitness is a variable size so it's better trying to feed double to your pull back from stand by it [Music] I guess hash story is weatherproof disco so instead of getting a g-string brief you get just a hash which you can used to pull down the uproot for my passage back row you can there's a different proof through storage this is the last one so this is how to follow the penalty of manual don't break this is so running this is difficult here is a way you can run so again we import our API of dock and this is running mate ourselves we're gonna use this time but key on this one is we're using now the reason easily and enter is but the intrepid fights creative the environment areas one thank you one way is to actually use the random number generator on the letter itself to create there under bytes and next is to use the key of the ledger to say hey I created those places eventually so this is why for our random basis of we used to mention proof type and again this means you have two personal engine people that manufacture the budget of the trust as anymore because you can verify that it's a legit business so once we've set up this is how you get your randomness so this time we're using what we got we've call it to get through more random bytes functions we're going to ask for seven bytes of delay that's a new thing there's a parameter you can have if you like and it's a delay which is to say approval give me a query result we do it later so if any of you written smart on trust when you want something to call it after a day that's kind of hard to do it can't be pulled itself and you can't delay in if you want to but if you make a provable query you can so in this case I think I made the delays here it is well you can't have that minute up to sixty days whatever that is in unikz sorry inseparability and the core i guess it's okay which is another thing which is that when you make a provable query it is the provable service that calls it the callback function and in order to do that it has to have gots to do it and of course we want the contract it makes that whole to be the one to pay that gas so you define how much gas you want to be taken out of your contract at the time of your opponent in order to power that callback Elizabeth now in this case we've passed for 200,000 of course what you wouldn't do in practice is run your whole book itself to find out how much gas of colors and then ask for that you're not wasting you can also burn the caller without gas plus if you want to bother to be the one paying for the query which is you space so common in fact that an example is in the etherium examples are not able to show you how to burn but in this case we are asking for - 2004 by gas to power I'll go back so this time we're not going through bullets for query were calling provable new running PS query yes they saw steak sauce and passing it I'll delay our number of quite from our pockets and that's it here we are the same format as all the restaurants and it's go back three parameters clearly the string of the result and the fights that are approved in this case though the reason this example is here is because of the ledger proof and because of the way it's set up we can verify the legend proof on the chain which means that you can switch in your contract on whether or not the old proof a lead or not so the other proofs and the different ways they were clear that was a little code various different ways to do it you can validate them off chain because the size of the proofs and the way that you have to answer certain services that they did think that it's impossible on chain of the ledger proof because it's both small and the code we wrote so it means that you can validate that on change which is critical because now especially with running this it means you can trust the randomness as fashion practice which on whether or not the ambassador so it's a bit of a mouthful the function that the approval is what remand es let's go through verified underscore return code and but over there is pulling a function that's in the API it's taxing it the pieces of data we got back and say does equal zero so sorry if it does we're saying hey after class remember we can do what we want with our randomness and the else I want to go through the last bit of joke there which is about the power outage burning our bytes into a random number that's just so much well basically all the saying is paid over some random points from a ledger how do I tell a number and so that one is the last and probably most advanced example I'll show you today I had to get a randomness so but you still do pretty much everything I did about it except the politic which is to say all I showed you today are the URL data source and the random data sources but we also have a Wolfram Alpha big sausage or a Wolfram Alpha period we could do nested query as nested pairs of code which is if you want to say hey I want some randomness but then I want to use that randomness to make the URL query that would be a nested data source you just chain chain with encrypted berries they're great what if you're calling a URL that has a password or it has some form of credentials you don't want those credentials publicly on the blockchain well we have an encrypted query so you can crypt it so it's on the blockchain but nobody read it and then the last one is the real powerhouse of this beauty taster is the computation data source which is where you say hey make me a query and that query can be in you want and how it works is that we spin up a AWS instance and run a double file of your providing inside that copy you can run whatever code you like so that we think it's basically query your docker file how it run its code whatever it returns is what the provable service returns to you which means you can now do arbitrary computation that fits in a five-minute window caveat on a stop it with a small contractor so you can basically do anything you like now you know American scientists solidity to block sizes and gas amounts or anything so it's super cool and oh there was another example I don't have time to escape this is a pretty verification tool down here to prove the Barrett money to be able to proofs I mentioned although the ledger and the run the base was very visible they all change for the other ones and finally these two extra tools are ways to do that the test query tool is stretch the top one will be abused to you if you're using this because half of them because it's a very good way for you to throw URL at it and see what these be back so you don't have to do it by a small contraction just put on that tool and say hey what does that give me back you'll see exactly what provable return to your smart super quick to figure stuff out there and finally congratulations your approval expert after that whirlwind tour but where importantly get using our API in your hacks generally hear that once by contract prepared query it doesn't seem flexible at multiple why not boy you have that very square squirt callback everything when you make a query I didn't mention this little query when you actually roll through book very it returns to you the query ID so all of those that is called it's there are some simple that you can choose I could get a return on that which is a query ID my query ID is boys the first parameter in the core line which means you can switch I'm very happy so you can make multiple query types and restore the idea anyone yes yeah WIC and pretty ironic pre-wedding front it's all true yeah yeah yes so we have integration of cooling on luminous but basically at the minute with the etherium bridger type the reason Eclipse though if you have anything that is a theory and that idea based it will work out of the box so it's that simple and or the ones that aren't quite the same thing again like the Oh a system

Automatic transcript — names and jargon may be misspelled.