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

Loading player…

Michael Dong I How to Build data-driven dApp with Brevis ZK Coprocessor I ETHGlobal Bangkok 2024

ETHGlobalThu, Oct 9, 2025, 12:00 AM

Join us for a workshop with Michael Dong titled, "How to build data-driven dApp with Brevis ZK Coprocessor." This workshops anticipates ETHGlobal Bangkok, a 3-day hackathon happening from November 15 to 17 2024, bringing together the most skilled web3 developers, designers and product builders from all around the globe for a weekend-long adventure to advance the Ethereum ecosystem! ----------------- Follow us: https://x.com/ethglobal Check us out: https://ethglobal.com/ Email us at: hello@ethglobal.com

Transcript

[Music] hi uh this everyone this is and before we dive into the details of the apis and SD case just want to give you everyone a quick introduction of brevis as a whole so brevis is a Smart offchain verifiable Computing flat platform what do I mean by that is that it is fundamentally a scaling solution so basically you know we have a very limited computation capability on blockchain tell you like some examples you can actually use breev to offload this computation to an offchain environment in that offchain environment you can run another computation but not only just the computation itself but also generate a ZK proof of that computation result and we you can then submit both the proof and the computation result back to the blockchain where you can actually simply and cheaply verify the competion result most of the computation happens but instead it becomes a glue point of verifiable computation resources what this means is that you can actually expand and scale blockchain computation to an infinite level because in fact you can actually itself is a single threaded computer that can only run one application at a time there's no way to parallel processing this and uh we build something called a ZK C processor as as as our first Flagship product so ZK co-processor allows your smart contract to have access to historical onchain data such as event transactions and build using breev one good example is intelligent defi where you can dynamically change the protocol parameters of D5 projects for example you can actually run a fee trading volume based fee discount by allowing user to prove on you know incubator programs with Unis swap foundation and Atrium uh to kind of demonstrate this you can just search online and see some of the examples building with this and you can also do consumer facing applications for example we partner with Euro which is rising star in the stable token space and we power their token launch program so instead of one off airdrop now you can allow user to continuously generate proof of their interaction with a protocol and convert that into a quantitative Matrix where they can use type of a oneoff jrop so thing so this allows you to actually merge and align user incentives with um you know your protocol growth by having this continuous Evergreen program of token drops there are many other things you can do is a brev like pre-confirmation you can essentially um you know prove a 2d block watching whether a certain block producer have included your transaction or not in the past and you know you can do slashing and rewarding based on that but using pris uh you know SDK is quite simple you specify what kind of data you want to read what is the the comutation logic you want to run and finally you have your uh entire computation logic integrated in the smart about a very specific example of how you can build with brev using a Unis swap V4 hook example but you can generalize that to other applications as well so Michael all right um thanks everyone for going to do a uh uh summarize the trading volume of a specific user on Unis Swap and uh I'm going to focus Less on the Unis swap V4 hook in this talk uh but more on the abvious side of things so uh first of all let's look at how a braev sa workflow looks like uh so as you can see we have multiple components and and we have the app service the brevis service and the contracts associate with it with the app and brevis uh so the first step uh is pretty standard uh you just like use any sort of indexer or you can just build your own to get the uh blockchain data uh like the historical blockchain data from uh from onchain so basically like use say like the graph or use your own like eum RPC node to create the ethereum blockchain and then you feed all those data to the app service which uh like in the uh rectangular Brew box that you built and um like all those data gets fed into the app circuit which is also like one of the components uh you guys will build and then once you have all those uh data and processed by the circuit like essentially you generate a u like your part of the proof and then you send all those and then brevis is going to like combine the two to generate a uh the final ZK proof to be verified on the bravis contract for the any sort of like post-processing Logic for example like in the Unis swap case uh like as soon as you can you get a sum of all the trading volume for the user in the past 30 days you can like assign the user a VIP status based on their trading volume and with Unis swap V4 hook you can like uh lower the uh like transaction fee or lower the swap fee for for that particular user which is quite useful so this is essentially a simplifi version of what I just talked about and in this case like we we provide the uh typescript SDK or the or go SDK whichever you prefer and you implement the um uh approver service which we have a template for and you don't have to like write any code essentially and you just submit your uh proof which like you guys will implement the app circuit which we also have very extensive examp okay so uh I think this is based on our typescript SDK we also provide a go SDK as I said and you can pick connection to the uh uh app prover which was the U the top like blue box and we have a template for and you don't have to actually worry about uh implementing that so like once you establish a connection you uh like instantiate a new proof request and you're going to filling all the data so in this case um we're going to we looking at Unis swap swap events right so and for us we only care about it being a um Unis swap um I think this is from a usdc to etherum to ethereum I believe and um in this case like uh it's a little bit technical but you can see that you provide a transaction Hash a swap event and one of them is from the actual um usdc transfer event and the uh the the data we care about is uh amount zero which is a b believe the usdc amounts and also the the recipient so that we can verify this is the uh un swap because they have the uh the way they're like router contract setup I think either sender I think actually re recipient is supposed to be the Unis swap router and with all those uh we start writing the circuit so that was the the the providing the data part and this is done if you're using typescript this is going to be done in typescript and the actual circuit we still have to use goland and um it's not too intimidating it's a like pretty simp is going to um go and you have the allocate and and in this case you you don't need any storage or any transactions you just need the receipts and you can like specify a max number of receipts I'm not going to go into too much um detail like how you're going to use our SDK to to like execute the the logic so um like how many of you guys know like map produ basic functions to calculate minimums or like calculate sums for like common I guess statistics use cases but you can also use the for Loops if you choose to um if that makes things easier as well so in this case we first do a map over all the receipts and extract the block number users volume in the past uh month right so we kind of need the minimum block number and also verify that it's like from the past month and forward and very simple to uh to implement and once we have the computation done we have um we need to Output the results so that the um the aching contract can make use of it to say like assign VIP status or like give our reward whatever volume and we also need the minimum block number for the onchain verification and we also need to Output the actual user address to make sure it is for that particular user and this is the uh uning contract part of the uh bravis application in in like you require VK hash equals VK has this is more like technical detail but you can just copy it the idea is that that every every braev circuit is going to that this is the correct circuit um because otherwise you can like have some other logic which doesn't match the actual circuit and that would not that will be I'll present in the next slide and in this case like we we don't actually do anything with the output we just emit a trading volume and test it but in reality you can just do whatever like you can uh attach you like put all that in a Unis V4 hook so you can like lower the trading fee for the user and this is the actual decco logic which uh it's a little bit intimidating but it's actually quite simple if you just read through it um you basically match whatever the circuit has like in the comment section you see all those uh API dot so you you essentially just extracting different bits or like bites from the uh output and you like return that and here are a few links that can help you get started uh we have a pretty extensive documentation and examples so just go to docs. bra. network or check out either one of the two sdks whichever language you prefer [Music] and okay question one uh this as I see this is something like a CK as a service but you hidden transactions or hidden data that people shouldn't be able to see yeah uh that's a good question so yeah as you said so in this particular use case right there isn't any like there isn't too much privacy I should say but well like whatever we output is like whatever we care about on chain right so in this case you don't have to have to like publish the uh all the uh individual swaps on chain kind of like aate the actual like swap events and you can still only output these ATT tested like volume as well as the user address okay but they don't have to be public I guess is maybe that's what what you're asking so yeah there is some privacy nature to it but you can make it more private by uh okay I think if not um we can just uh check out those links and uh start hacking and if have any questions just come by our boost and we'll be happy to answer [Music]

Automatic transcript — names and jargon may be misspelled.