[Day 1 - 05] Building xChain Apps with Arjun Bhuptani
BUIDL Vietnam 2022 · September 2022 · 22:01
Arjun Bhuptani, founder and CEO of Connext, explains how to build applications that work across several chains. Using Aave as an example, they show why switching chains and bridging by hand is a poor user experience, then address bridge hacks through modular design, fewer external dependencies, delays and rate limits. The talk introduces Connext's xcall primitive, an asynchronous cross-chain call modeled on JavaScript, and shows uses such as cross-chain governance, with an outlook toward connecting contracts to decentralized storage and compute.
Speakers
Topics
From BUIDL Vietnam 2022, hosted by Kryptoplanet.
Transcript
please welcome Arjun book Penny he's now the CEO and founder of connects Arjun is The Mastermind behind connects a groundbreaking protocol that powers secure generalized communication between blockchains and now he will share with us his thoughts on how to build an interoperable applications that help leverage the infrastructure and ecosystem of multiple chains let's welcome him with a speech building action app foreign [Music] that's me
um I'm one of the founders of connects connects is a a protocol that allows you to communicate between blockchains so in today's very very interesting multi-chain World connects is a project that allows you to kind of solve the fragmented experience of having to interact with applications that live on multiple chains at the same time so here's an example this is Ave uh how many of you use Ave awesome Ave is a lending protocol that is built on top of ethereum and then also all of these other chains when you use Ave today there's this really confusing experience where you have to go and select a change specifically that you want to to lend on or borrow from
um and in order to actually find the best rates on every chain or on all the chains altogether you actually have to go through each and every single chain independently not only that but if you if you're kind of interacting with Ave and you decide hey I've lent funds on one chain and then you decide you actually want to unwind your position and move to a different chain you have an even more confusing experience where you have to pull funds out of Ave leave the Ave application go to a bridge bridge your funds to another chain and then put those funds back into Ave for most people especially people that are new to the space this whole experience is nonsense it doesn't really make a lot of sense to go to send your users to another
application and it also doesn't really make sense for users to have to learn what a chain is in the first place right users want to use apps they don't necessarily want to learn how the technology behind a given given decentralized application actually works so how should this work the right experience for Ave is to have a single unified interface like one one place where you just borrow and lend and in the background Ave should actually take care of the process of sending your funds to one chain or another right and that intuitively makes sense you don't you don't when you're using Google today for example you don't and you look up you know cat videos you don't have to consciously think about where those cat videos are stored you don't have to think about okay the the references to these cat videos are distributed across
a bunch of sharded databases in Google servers you think okay I'm just going to see an application interface that has videos on it the experience that we are building in this space really matters because ultimately in order to be able to scale in order to be able to bring on people from outside of the space we need to make sure that we mirror what actually happens in web 2 as well so um I've been talking a lot about cross chain uh and I think that makes people a little bit nervous because cross chain is a bad word and there's a good reason for why cross chain is a bad word in the past year we've lost about two billion dollars to hacks in bridges it's a very very large
amount of money it's no secret that the the bridge ecosystem and Bridge's reputation is actually in a very very bad place and there's there's a really really good reason for it so how do you actually like do we even need bridges in the first place why do they actually exist now the unfortunate thing is that one thing we've realized over the course of trying to build applications in this space over a very long period of time is that in order to scale you actually have to move to multiple different blockchain like environments you can't have build every single application on a single blockchain it doesn't make sense um ultimately you hit the same scalability limitations no matter what what blockchain you're using because ultimately there's physical limitations
to how how uh basically how how large you can scale a single distributed system so do we really need Bridges well um regardless of whether you believe in a multi-chain world or if you believe that we're heading towards a world where there's multiple Roll-Ups building on top of ethereum or you're in Cosmos and you have the interchange ecosystem or your polka dot and you have another interchange ecosystem ultimately you actually need to be able to communicate between these blockchains and so it's all bridges right Roll-Ups posting data to ethereum is a bridge data availability layers posting data to sediment layers is a bridge Roll-Ups being able to communicate between each
other also a bridge eventually this whole ecosystem just becomes Bridges and layers so if we if we're forced into a world where we have to have Bridges how do we build them safely this is actually the really big challenge a lot of the bridge projects including connects are facing currently um how do you actually build infrastructure that's so critical in a way that it doesn't break and it doesn't get hacked and when it does get hacked how do you avoid the risks of things like contagion so contagion is this thing where if you have for example a polygon right the polygon POS bridge is how you bring assets from ethereum over to the polygon ecosystem how do you stop the the risk if that if the if the
polygon Bridge gets hacked how do you stop the risk that the entire polygon ecosystem just disappears overnight um and that is you know again billions and billions of dollars in value that can just vanish so um some of the things that we've been looking at are modularizing bridges what that means is basically breaking out each of the different components of bridges uh in a way where you can separate out the risks of them independently so for example uh have transport which is how do you get data from here to here um basically simple hashes from here to here be separated from verification which is how do you enforce the security of those hashes how do you enforce the the correctness of them and have all of that be separated from liquidity so how
do you actually bring liquidity and value between chains the second piece that I think is quite important is minimizing external dependencies so if you look at a lot of a lot of the bridge hacks um for example the Wormhole Bridge hack right the the Wormhole Bridge hack was caused by a cryptography dependency on Solana that was actually implemented slightly differently than on ethereum and that cryptography dependency had a vulnerability in it this is kind of the risk that you take when you're building on top of blockchains especially a lot of different kinds of blockchains is that you you kind of you inherit any security issues that they all contain and in in wormhole's case one small issue in work in Solana caused a 350 million dollar hack
next one of the one of the key things that we're seeing is using delays so do you need to be able to send uh you know hundreds of millions of dollars across chains immediately probably not right I think it's in most cases if you're if you're a fund or a liquidity provider or Market maker that is transferring 100 million dollars across chains you're probably okay with waiting 15 to 30 minutes and that delay is long enough to be able to to have off-chain actors basically what we call Watchers watch the chains and make sure that that that transaction is bona fide make sure that that transaction isn't happening as a result of a hack and that actually brings me the last one as well more generally just rate limits you know how do we how do we stop the the risk of hacks in this space is just
to implement rate limits that stop an attacker from stealing all the funds in a single transaction right so if you if you limit the ability to withdraw funds so you can only withdraw you know say 10 of the funds in five minutes you can shut down a system before all of the funds are lost and I think that this is true not just for Bridges but also for the default ecosystem overall and a lot of the the core research that is going into security here is going to be applicable to the rest of the default ecosystem so um what is connect and how does it work connect is a mechanism to communicate across blockchains the way that we minimize risk is that we try to use existing Bridges as much as possible we try to use ambs which are basically
which are arbitrary messaging bridges that exist within a given ecosystem so for example um you know the the polygon POS bridge is an A and B The gnosis Chain Bridge is an amb but this also includes things like the roll-up Bridges so the bridge to get into and out of optimism and arbitrum uh by using those existing pieces of infrastructure we're limiting the risk additional risk that a user has to take on as part of interacting with interacting across chains so uh you know if you're a user that is holding assets on polygon you're already taking on the polygon POS Bridge risk so we we can basically avoid having users take on additional risks that they would not have had to take on otherwise and of course in most of these cases you
have uh delays within baked into the ambase so in polygon this is uh three hours exit or I think it's two hours now to exit um 15 to 30 minutes to enter uh in a roll-up that is seven days to exit and then a few minutes to enter um so we have a basically what what we call an execution layer that sits on top of this this lower level ecosystem of bridges um and that execution layer allows you to make transactions happen quickly as a user you don't want to wait for seven days for your for your transactions to go across chains in the first place and so our execution layer just makes the transaction happen immediately this happens through a network of off-chain actors called routers and those routers are then
repaid over the slower ambes that was a lot that was very very technical um jumping back to kind of the higher level PCR what does Connects actually let you do it lets you build cross-screen applications safely um we think that if we figure out this bridge problem if we figure out how to make secure bridges in the first place the future looks like a world where every single application will be cross-chain and this is similar to how you build applications in places like JavaScript so um uh we introduce within Connexus primitive called x-call uh xcol is a simple mechanism that actually maps to the lower level solidity call function
so solidity has a a call function that allows you to call a contract on us on the same chain basically just execute a transaction against some contract function on the same chain X call is the same thing but across chains so rather than doing a synchronous call to a function on the same chain you can do an asynchronous call to a function on a different chain this is really really similar to how JavaScript works and in fact a lot of it a lot of these core ideas are the same right why why does JavaScript and why does web development look the way that it does why do you make asynchronous calls across like to to get something in JavaScript well it's because the server that you're fetching data from exists on the other side of the planet and so you don't know on the internet you don't know if that Trend
the the request that you're sending is going to get a response you don't know how long it's going to take to get a response and so you kind of have to shoot it off into the into the uh into the dark and see what happens and while you're seeing what happens you can go and do things right you can continue the execution of your program and you can just wait for that data to come back xcall works in the same way with asynchronous solidity you can make a transaction to a different to a contract on a different chain in the same way that you make a transactional contract on the same chain but because it's on a different chain you don't know that that transaction is going to happen immediately I mean it's not going to happen immediately right it's not it's not happening within the same block like
it would in a normal transaction and so now you have this asynchronous Paradigm you x-call across chains and just like JavaScript you can optionally also specify a callback which returns data that that from like a function on a different chain that you can then use to execute something again on your Source contract nope um there's supposed to be an emoji here but it's gone um so one of the things that makes this particularly interesting is that we've tried to make this behave as closely to existing solidity development patterns as much as possible so for example um you know gas fees how do you actually
pay gas across chains that's a that's actually a really really difficult technical problem right because when you when you pay fees for a transaction on a single blockchain you are executing whatever is happening in that transaction and you know after the execution is complete exactly how much should be charged and so fees are taken from your account right away as part of the same transaction but across Chains It's a little bit of a different experience when you execute a transaction across chains you don't know how much it's going to cost you because you don't know when it's going to get executed you don't know who is going to execute it and you don't know what the gas on one chain so if you're on ethereum you don't really know on ethereum how much the price of gas is on polygon at any time
what we've done is basically try to keep this as simple as possible um so when you make a cross chain transaction you pay gas on your Source chain in the same using native Assets in the same way like that you would with any other transaction and if it's not not enough gas you can bump gas again exactly the same experience that you would have with building an application in solidity today um and then you know if you if you bump gas that basically means increase the amount of fees that are given transaction if you didn't have enough fees to begin with bumping gas basically can help it push it through faster in practice this is what it looks like um it's simple right I mean it's it's designed to be simple and despite being
so simple we think it's incredibly powerful um because it's such a generalized primitive because it's such a generalized way to actually build things you can build pretty much anything on top of it so these are some of the examples of projects that we've been we've been working with and and I kind of I'll kind of like step you through the constructions of them so you can see like the the kind of domain and scope of the types of uh things that can be built in this cross chain world um super fluid is uh is basically a money streaming protocol so super fluid lets you uh if you for example you want to pay somebody instead of paying them either up front or paying them on a monthly recurring basis you can put money into Super fluid and it just pays out uh money on a per block basis so
you're basically called real-time Finance um so for example if I decide to pay somebody a hundred dollars uh I can over the course of a week I'm basically paying them a certain rate per minute and that person can receive you know x amount of dollars per minute uh and then withdraw everything that they have received so far it's a really low risk way to do payments especially in decentralized communities we use super fluid actually connects uses super fluid to pay about 80 people in our community um and they're paid on a daily basis um one of the big challenges of superfluid right now is if you're if you're an ecosystem that is across chain so for example with connects we have users that are building on top of polygon on top of gnosis chain um and a bunch of other ecosystems as
well those users need to be able to be paid out on whatever chain they're on but having to for us having to go and set up super fluid streams on a bunch of different chains altogether is an extremely big operational like there's just a lot of operational overhead there so one of the really interesting Primitives that superfluid is building on top of connects is cross chain money streaming um being able to set a stream on a certain chain and then have it be paid out on any other chain and in fact you can use this not just for for like payments but also things like airdrops right you can use it for liquidity mining you can use it for other mechanisms where users are having to be paid on a recurring basis potentially across multiple chains at the same time keeper is another really interesting
project so I think keeper is quite well known because it was created by Andrei coronier keeper is a network for automation of solidity smart contracts so basically there's a there's a network of actors called keeper Bots that uh submit transactions to blockchains on on a recurring basis it's a decentralized network and they're held accountable by like a staking and sashing mechanism one of the things that keeper wants to move towards is also becoming a multi-chain network so being able to enforce uh being able to to do the same kind of activities that they do where they you know for example on on yearn will like call the Harvest function which allows
to uh or actually I don't really know what it's called but we'll call a harvest function that allows them to like update yields on their on their specific contract um so in order to be able to do this across chains keeper needs to build this broader multi-chain keeper Network and one of the key Primitives there is bringing t-wops across chains so uh you need unit swap team Ops are basically Oracles of price that exist uh with like based off of like the unit swap trading data one of the biggest difficulties that projects face including keeper is being able to access that Oracle data on any chain at the same time fujidao is another really interesting one so fujida is actually solving the problem that I talked about at the start of this talk which is lending aggregation how do you have a single
interface for something like Ave Fujita also does it on top of compound Trader Joe a bunch of other project protocols but the core Pro the core idea is very very simple right it's lend on any one chain and borrow on any other chain intrinsically that feels like the right experience to give to users um nft Hashi another really really interesting project it's an nft bridging and cross-chain nft protocol so right now if you're building an nft project your nfts are locked into a single ecosystem so nfts building on polygon cannot actually trade on uh you know arbitrums uh what's it called the the marketplace that's on Arbiter um or nfts building on top of optimism
can't trade on openc that's a really fragmented and siled experience and it's also really bad for the marketplaces that want to be able to get the largest user bases they can and if tehachi solves that it allows you to have nfts that actually exist on multiple chains at the same time or can be brought to it any other chain and lastly gnosis zodiac so gnosis is building this uh within the nocosystem ecosystem there's a there's a project called zodiac which is basically building dowtooling one of the key things that they want to enable is cross-chain governance so being able to have a proposal that exists on one chain be executed from any other chain and a good example of this is for example for instance a uni uniswap needs needs to like update their their fee tiers on
polygon but uniswap's Dao exists on optimism how do they do that um uh the the goal is to move towards not just being able to do things like that but also have cross-chain voting so allow users to have uni tokens on any chain and vote with them from anywhere um again it's intuitively this makes sense right needing to be able to bridge your uni tokens to to vote is something that people just won't do uh it costs money and it takes time and people it's already hard enough to get people to vote as it is these are some of the the like key examples of people that are building on top of us already but there's other things too that I think become really possible once once you have like generalized cross-chain communication that can be built securely into any chain one of the ones one of the ideas
that I'm very very interested in is how can we expand the scope of building on top of blockchains Beyond just having smart contracts running on top of something like a roll-up right um uh a a smart contract running on optimism has a very very limited scope of functionality and that scope of functionality is basically just like executing relatively simple code but what if you could actually connect contracts running on top of optimism to filecoin or our weave right what if you could actually bake storage directly into the execution layers of all of these different chains well that would allow you to build full stack applications on blockchains um that's like a revolutionary idea imagine building Google on a blockchain you could do that and in that in that
world basically what's happening is optimism or whatever your execution environment is is doing the compute it kind of is like an Amazon ec2 instance it's communicating with filecoin or are we for storage it might be working with other kinds of compute networks perhaps GPU networks like Golem basically any kind of decentralized resource Network that has a VM can can be plugged into this broader Network um anyway this is a little bit of a taste of what cross chain means how Connex is thinking about it and how you know the world that we believe can exist once once this problem is solved I think that they're still very very early a lot of people are still just now starting to
grasp some of these ideas I know for a fact that for most people like even the concept of I could have an application that lives on top of multiple chains simultaneously is a is a very very novel idea and so where uh really only just getting started with exploring this space um thank you so much for listening to the talk if you have any questions about this definitely come and talk to me afterwards because I'd love to talk about cross chain stuff thank you Adrian [Music]
