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

Loading player…

Axelar 🛠 Build Interchain - A Workshop

ETHGlobalMon, Oct 9, 2023, 12:00 AM

Build Interchain workshop with Axelar ! Some of the most skilled web3 developers, designers and product builders from all around the globe came together for a weekend-long hackathon at ETHGlobal New York 2023. ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com

Transcript

foreign [Music] agenda for today briefly we're going to go over the need for interchange how we got here why this matters uh the problem with pairwise Bridges as they've existed over the past few years an overview of the Oxford Network and the advantages which it brings and then we're going to get into General message passing otherwise known as GMP which will hope this will hopefully be interesting for you guys this is what our bounty's on is best use of the GMP I'm going to go through a code example of it and then we're going to end off with Axel on the Wild and some fun stats so a bit about myself I got into the blockchain space in late 2017 and I'm sure many of you have the same experience for me when I was trying to get in I would go to many meetups that was my thing I try to meet as many people as I could make friends with the 20 people and what I noticed is that you go to these events you don't know anyone and everyone seems to know a lot more than you and everyone is extremely opinionated and many people at the time were trying to promote uh certain projects within which they were involved in so there's of course ethereum but there were also projects that people were kind of promoting it's like the ethereum killers there was Neo which was branded as like the Chinese ethereum there's Iota Tron EOS which was branded as like ethereum on steroids because it was faster and cheaper and this mentality that people had at the time was that of chain maximalism this idea that there will be one blockchain to rule them all and the rest will kind of die and I think it's safe to say Looking Back Now that what we've learned is chain maximalism is wrong this never actually happened instead what we saw was the rise of more and more blockchain and if I could find my mouse here this is a brief screen uh screen screen recording I have from a website called chain list and what chainless does is it shows you the list of many of the blockchains that exist today I say many not all because it's impossible to actually know how many blockchains exist today what I'm trying to show you here is that you can see just on chainless there's hundreds if not thousands of blockchains that exist today and for our space to be successful we need to find a way to connect them and this question of interoperability if I could get out of this this idea of blockchain interoperability is nothing new we've known for years now we need we need to have interoperability for the web 3 space to be successful but what we saw was the rise of pairwise bridges which were using like wrapped assets and multi-sig um to handle actual transactions between the chains and the problem with multi-sig contracts is Bridges is that they were extremely um vulnerable to attackers especially if the keys were compromised and you can see here some of the more famous headlines I pulled up there are many more than these but these are some of the famous uh headlines of some of the biggest hacks that we've seen the most famous One probably being the 625 million Ronin Bridge hack for all you actually infinity players out there but there's also like the poly Network hack that happened just a few months ago earlier this summer uh who had a three of four multi-sig uh key compromised and more so this interesting article by Chain analysis they estimated that in 2022 uh 69 of all funds stolen in crypto it's about 2 billion US dollars that was stolen um was actually a tax on Bridges so let's pause right here what do we know we know that the number of blockchains is rising interoperability is more important now than ever before but we as a space can do a bit better in the way we conduct interoperability and that is where axillar comes in so axillar at its simplest is a blockchain that connects blockchains enabling Universal web3 interoperability that's a bit of a mouthful I don't expect you to take a lot out from that so let's actually dissect this um we're going to dissect it by looking at the oxide Network so this is the easiest way to actually see axler it's a hub and spoke model and I want to focus on the last three words from the previous definition I had Universal web3 interoperability why am I focusing on that that's because if you look at some of the blockchains here you can just just notice it we have ethereum Phantom polygon these are examples of blockchains running the ethereum virtual machine we also have projects like osmosis uh Juno the cosmos Hub um region Network these are projects built on top of the cosmos SDK um that are using combat bft consensus we also have arbitrum we also have a linear base so I don't think those two are on this on this diagram here in total we have 49 blockchains right now that are all connected with axillary and these are different blockchains with different consensus mechanisms different virtual machines we have app chains that are on here um you want to go back to this um so that that's its idea of universal web free interoperability and the two major improvements which axelr brings right out of the box are that of scalability improvements and security improvements let's talk about scalability first if you picture pairwise Bridges sorry I know it's a bit hard to read um but let's imagine we have three blockchains in blue we have ethereum and yellow we have BNB and in purple we have polygon now to connect each of those three blockchains to each other for three chains we need six Bridges to connect each blockchain to each blockchain so we want to add a fourth say Avalanche just for that one extra blockchain we're now at nine Bridges to connect all these blockchains and you can imagine like with what I was showing you guys earlier on chain list where there's like thousands of blockchains that exist to connect each blockchain to each blockchain or anything I don't even know how many bridges to connect each of those but the point is that number doesn't really scale and if you contrast that with axler we have a hub and spoke model all you need is one connection to the axillary Network and then you're connected to all the other blockchains that are connected with axler and I like to think of this in my mind as like these pairwise bridges are kind of like train tracks you can go from point A to point B and that's it whereas with axillar it's more like an airport all you need is a connection to axler you just need one airport in your city and then you can connect to any other city in the world that also has um that has a blockchain um so that's a scalability improvements if I go back to my second Point here there's also security improvements and I touched on that a bit um but axillar is a blockchain of blockchains so what does that mean it means that we currently we're built on top of the cosmos SDK we currently have 75 live validators uh anyone here in the cosmos ecosystem might be familiar with some of these validators like figment informal systems poker 2 these are well-known validators who are also validating many other chains in the cosmos ecosystem as well and this is a tremendous step up actually having a blockchain to handle interoperability that compared to just like a multi-sid contract but now now that we've covered the use case and how axler is helpful let's look at what we can do now that we couldn't do before and that is General message passing and this is the exciting part I hope for you guys because it's what our Bounty is on at its best use case of GMP so what is GMP or general message passing it's this idea that we could actually send a message between one blockchain to another pretty straightforward and you can see myself on ethereum this is a picture of me for my first ever blockchain Meetup um I spent way too long looking for it and this is me here on Avalanche so on the first message I'm sending like wag me like are we gonna make it in this crazy amazing space that we're getting ourselves into um and then from Avalanche to ethereum I'm sending a message called safe mint 5 board apes and what I'm trying to show you here is that in addition to just sending like kind of silly little hello world messages you can also actually call functions between one blockchain from another blockchain and that is true interoperability it's the idea that we can actually interact with contracts and applications on a different blockchain as easily as if they were on our own blockchain um so a very brief diagram here I know the text is a bit small I apologize for that but a brief diagram of how GMP Works um so imagine we have if let's start from the bottom left corner there we have our amazing hackathon project and we've deployed that on the avalanche blockchain on the right we have also deployed that application on the polygon blockchain and we want to send an erc20 token from Avalanche from our application there to our application on polygon so the first thing we have to do is interact with something called a Gateway contract a Gateway contract is a contract which axler has deployed on every single blockchain that it interacts with so the Gateway contract exposes several different functions including call contract with token so step one you have your dap your dap does some amazing idea you're going to import the Gateway contract and from the Gateway contract you're going to call this italicized call contract with token that jump starts a process through the Gateway contract which emits an event the event is then picked up by the axler network the actual Network member is a blockchain with 75 validators those validators come to consensus about the message that was sent if they're all on board we're all happy they send a message to the Gateway contract on polygon on the destination chain that the message was approved and then via something called a relayer the Gateway contract triggers step 4 execute with token this execute with token is a function which you're going to Define yourself in your contract and you can do whatever logic you'd like with it with the message that's coming in you see the bytes 32 payload and we're going to go through a quick code example so you can see that in action but one more time high level your application is deployed on two blockchains you call the call contract with token from the Gateway contract under the hood Gateway emits an event picked up by the axillary network axler network lets the other Gateway on the destination chain know that hey we're good then the Gateway calls uh the execute with token function via relayer so let's see this in action and sorry I know it's a lot but um time to get through a lot in a little bit of time so for time's sake I'm not going to write out this code we'll see how we're going to do it but what we're doing here is we're trying to implement the previous example which is to send an erc20 token from Avalanche from The Source chain to polygon our destination chain so first thing we do is import our erc20 interface from open Zeppelin pretty standard we then import the axillary executable which I will get back to in a bit sorry this is small let me make a bigger this is as big as it goes are we happy can we see this okay next thing we do is import the axler executable which I'll get back to then we import the axelr Gateway contract is this familiar to anyone ask for our Gateway that is remember this guy the Gateway contract which is going to expose the functions that we need to interact with so we import the interface for that we then import the interface for the gas service this is the other very important contract which I conveniently left out of that diagram so let's think about it if we want to send a transaction from Avalanche to polygon we're going to need three different tokens one avax for the Avalanche blockchain two Axl for the axillary blockchain remember axillar which is facilitating this is itself a blockchain and then three Matic that is the token of the destination chain polygon though I think they're changing the name of that um and the problem is like I don't want to hold three tokens every single time I want to send a transaction I don't think you guys do either so the gas service does it it extracts that difficulty we can just via the gas service tell her tell her um tell her contract like hey we need funds for the Matic for the polygon blockchain we're sending it from the Avalanche blockchain um and I know I am the person sending this uh transaction so now all you need is the token of the source chain if you're sending from Avalanche to polygon you just need avax and you're good to go and the gas service will handle the rest will handle the Matic and the Axl token so you don't need to hold all three that is what the gas service does if I go to step two here if I could find it the first thing we do here is simply in our Constructor we pass in the address of the Gateway and the address of the gas service remember every blockchain which axillary is on has a Gateway and a gas service if I go to step three we Define our first function which we're going to be using here this is a not a specific name sent to many I just picked this you can call it whatever function you want and send to many when you call this function it's going to jump start this interchain transaction it's gonna it's gonna be the function that you call to send an erc20 token from chain a to chain B and it takes five parameters the destination chain like hey which blockchain are you going to destination contract address which is this contract itself which will be deployed on both blockchains the destination addresses which I will come back to and then just the simple the symbol and the amount of the erc20 token that we're passing in so if I go to step four we have some pretty simple uh functionality here first we require say like hey make sure we pass in some gas if not revert then we grab the address of the erc20 token that we're sending we can do that by just passing in the symbol of the token to the Gateway we then have some standard erc20 stuff we transfer the tokens from me to this contract we then approve the gateway to be able to handle our tokens then we encode our third parameter our destination addresses which is the parameter I promised I'd come back to basically if you think about it all we're doing here sending an erc20 token from one chain to another but what's exciting what I really wanted to show you guys for the Bounty is General message passing that's overall that's what this is all about so what this third parameter is our message that we're going to be passing along with our token from one blockchain to the other blockchain and to pass that message we actually have to encode it into bytes um and that's what we're doing here if I go to step five I now interact with our gas service and our Gateway contract and for time's sake I'm not going not going to go through all this but basically what we're doing is we're telling the gas service like hey call this super Long Function pay native gas for contract call with token and we're telling the gas service like Hey we're gonna need funds for um for the polygon blockchain as well we then call our Gateway contract here on line 61. This is the call contract with token function which if you can recall is the function that we had defined here in our diagram which was being exposed to us from the Gateway so in our Gateway contract we say like hey we want to pass in the destination chain like polygon we want to pass in the destination contract address uh the encoded recipient addresses so like our actual message which is coming and then our symbol and our token amount and once we call this function we are going to have kicked off our interchange transactions so once I call this and all this logic gets executed our transaction will now be leaving the Avalanche Source chain and going to the Oxford Network which is great but if you recall the diagram we also need to do something on our destination chain so the transaction goes to axillar and then comes out the other side on polygon but like what do we do there so for that we have our final function which is execute with token and now this function is going to be triggered on polygon automatically and it's going to handle some logic with our message that gets passed and this is our final step here we're going to be taking our payload notice the third parameter here which is our message that was passed our list of addresses and then on line 90 we're going to take our amount of tokens that was sent because remember we're sending an erc20 token and a message so let's say we send six usdc or ausdc and we divide it by how many addresses we've sent and that is the amount that we're going to send to each address which is really really powerful because not only are we sending the token but because we're sending a message with it as well we can compute some logic in this case very simple logic but logic nonetheless that we're going to be doing on our destination chain after a transaction is sent and I executed this earlier today I figured I'd be short on time um but it's all done through the hard hat CLI so I'm not going to go through this but what I did want to show you guys is this transaction actually going through on the axillary scan block Explorer so remember since axillary is a blockchain it also has its own blockchain and you can see here the step-by-step of each step of the transaction process so you can see step one the transaction gets sent on Avalanche the gas gets paid on Avalanche the actual Network confirms the transaction I can scroll down here for more details step three is confirmed and approves the transaction and then the final step it gets executed on the polygon block Explorer and you can see here I can actually click right through from the axillar scan block Explorer yeah from the axillary scan block Explorer to the polygon scan uh block Explorer and you can see here our transaction actually our logic being executed we send six tokens and then evenly send two tokens to each of the recipients so that is a very high level of axillary GMP in action um the thing I want to end off with is some more fun stuff just axler in the wild so this is an application called squid which is being used today it might look familiar to anyone here who's ever used the decks before and you can see that what's cool about squid is that in addition to selecting the token that you want to send you can also select the blockchain you want to send so in this case I'm sending GRT from ethereum to usdc on optimism and this is all in one click uh like really really powerful stuff um and I want to end off with some stats here this page might look oh I didn't spend that much time on access again so a bit unfamiliar but this is from the axillary scan block Explorer you can see just some of the stats about the axillary Network you can see 66 000 transactions three billion dollars of transaction volume sent and the really exciting part is that this is just over the last 30 days I know it's a bit small but um it's a really really exciting time to be familiarizing yourself with this stuff and using axelr um here are some resources for anyone using for anyone doing the bounty on the left I highly recommend it is um a series of YouTube videos we have um just explaining this stuff and all the right is uh our GitHub repo of just examples using this stuff um and yeah thank you very much my name is Ben Weinberg I hope to see you guys around

Automatic transcript — names and jargon may be misspelled.