Cross-Chain Applications on Ethereum and Harmony - Ganesha Upadhyaya
Ethereum Denver·Sat, Oct 9, 2021, 12:00 AM
This talk is from ETHDenver & ColoradoJam , the world’s largest Web3 BUIDLathon and Community Gathering. ETHDenver’s content is crypto and blockchain focused. Learn more: ethdenver.com Subscribe to our channel to learn more + connect on Twitter: https://twitter.com/EthereumDenver. Speaker: Ganesha Upadhyaya This talk was recorded Sunday, February 7, 2021. ETHDenver 2021’s content themes included DeFi & Money Legos, NFTs & the Creator Economy, ColoradoJam & the Next Frontier of Statehood, Protocols & Interoperability, Open Source & Public Goods, The Ownership Economy & Digital Orgs, Usability Design & Adoption and Legal, Privacy & Identity. Industry experts also weighed in on topics like decentralization, privacy, identity, non-fungible tokens, scaling, governance, diversity, and arts and culture in blockchain technology. The 2021 event was February 5-12 and hosted virtually in 2021 with 5000+ blockchain enthusiasts, developers and community members from 80 countries and 50 U.S. states. 🔴 SUBSCRIBE ETHDenver’s YouTube https://www.youtube.com/channel/UCgz9NU06t_FkT0Py1Vadczw 💡 LEARN ETHDenver’s Official Website https://www.ethdenver.com/ 👋 CONNECT ETHDenver Twitter https://twitter.com/EthereumDenver 📖 READ ETHDenver News on Medium https://medium.com/ethdenver 🛍️ SHOP ETHDenver Official Merchandise bufficorn.com 💬 CHAT Telegram https://t.me/Ethdenver Discord https://discord.gg/AxFmNdCVnU 📱 FOLLOW LinkedIn https://www.linkedin.com/company/ethdenver Instagram https://www.instagram.com/ethdenver/ Facebook https://www.facebook.com/ETHDenver/
Transcript
okay so up next we have uh harmony protocol ganesha hey john can you hear me i can i can hear you just fine how are you good good how are you doing fabulously so you're going to talk about uh cross chain applications yep cool are you ready yeah i'm ready all right take it away sure um hello denver this is ganesh from harmony uh let me share my slides uh okay you see my slides right yes we do okay uh hi uh this is ganesh from harmony um i'm an engineer i work on building cross-chain infrastructure for harmony specifically something like a bridges and light lines and so on so in this workshop i'm going to actually put a put an ethereum application to harmony and that has some cross-chain aspects to it so here is the outline i'm going to first describe harmony in just one slide and then tell you about uh what is harmony for ethereum and then right get into the demo of putting an ethereum application to harmony and then if time permits we will talk about some of the more cool stuff so after this slide i only have two more slides okay uh in a one slide harmony is a layer one blockchain just like many layer one blockchain c3 ram near and so on and harmony has a two second block time and it also has two second transaction finality and it's a decentralized network of nearly 1000 nodes and it follows a traditional byzantine consensus slightly optimized and harmony is a started blockchain with the currently four shards with 250 notes each with the uniform security and harmony is also based on proof of stake um yeah that's about harmony so what is harmony for ethereum uh i'd like to describe this as a journey uh represented by these four uh blocks you see uh i call i would like to call this as a journey because uh we initially started with a fast and cheap blockchain uh that has a full evm compatibility uh we initially thought this was enough uh but it turns out uh when developers try to put their application from let's say ethereum to harmony they uh needed something to also bring their assets uh from ethereum to harmony so that required us to uh build the crosston infrastructure with bridges uh was that enough uh no uh developers although they like to use new tools and uh like to learn new libraries and so on they wish whatever works on ethereum side is also seamlessly work on harmony so there comes the ethereum tooling compatibility so uh harmony recently uh we were able to achieve full lithium compatibility in terms of tooling meaning that tools like metamask web3 js etherjs and all those fantastic tools work on harmony so uh if you would like to read more about these four pillars you can find some medium articles here i will share the slides after my presentation as well so you may think ethereum tooling compatibility what is the big issue right harmony being a started blockchain its transaction structure differs from uh a non-started blockchain so that creates a lot of complexity for uh making these uh tools uh really compatible so that's why it's a big deal for a shaded blockchain so with that uh let's get right into uh the demo uh where i will try to put an ethereum application to harmony so let me go here um my screen is still shared right here correct okay so i was wondering what is the right application i should pick to port and there is no best place other than eat denver itself i went through the uh last year there were submissions there's a lot of really cool submissions developers have put their blur sweat and tears uh in achieving uh in a short period of time so it i would like to say this is kind of a tribute to the developer efforts um so in these uh wonderful set of applications uh uh that are that were built in last hackathon last year hackathon i came across this len 721 or land uh nft application i found this very interesting so let's go ahead and open this application so thanks to this developer for providing uh such a wonderful application uh uh this application is basically a nft lending platform where lenders can lend their nfts erc721s and they can earn some interest in some other fungible tokens specifically this platform uses die as a token where the lender will earn the interest borrowers can like collateralize their dice and receive lend the nfts from lenders and use it for other purpose so why i think this application is that um this is simple enough for me to put as well as this has uh both fungible and non-fungible assets and both of these fungible and non-fungible assets exist in ethereum so i can use crossteam element to bring them to harmony and really show the application so this was uh an application that was built in the last year hackathon but recently in the past 10 days there were some activities so it's also deployed on e3 minute so let's go ahead and open this uh minute contract here so let me maximize slightly so let me go ahead and look at the last recent two transactions here right so here is the one and we notice what we notice is that this is a a transaction to basically lend or create a land request so with the 99 gba gas price it took nearly 50 so if we go ahead and look at now it will cost even more so the to perform to you really use this application people like lender and borrower have to pay a lot of gas fee similarly let's look at this transaction this is a remove landing again you have to pay a lot so just keep this in mind when we see what happens when this runs on harmony right so let me close this okay so to begin let's go ahead and clone this application so i'm going to go open my terminal here i'm going to do git clone lens 721 and then go inside this directory so to save some time i ran through this demo once uh and i miss uh i collected all my changes that i did into a pass so i'm going to do git apply uh my patch um card land changes and i am going to explain uh the changes i needed to make uh to make this uh to get this working on the harmony blockchain um so i applied my change to i don't want you guys to wait for uh the build of this application so i'm going to build this once uh okay let me just uh open this application while it is building i can also explain a little bit so let me do vm install so what is this application uh really it basically has a smart contract and uh i mean the version one version two and mainly to handle the nft lending and it also comes with a client nice client that i'll show in a bit um while this is installing uh what is the first step i needed to do like uh to make this uh the first step is to deploy this nft 721 esc 721 lending smart contract so let's go ahead and look at uh truffle config here so it initially had the development and some networks added to it so the first step is i need to go ahead and add harmony network so as your you guys are familiar on the truffle you basically add the network id and also point to the correct network url node url and some other bunch of stuff you need to specify to add a new network so for harmony you can find one way to get that truffle working for harmony and another way is use the truffle provider that is available in harmony.js sdk so i'm also using defining a configuration for that it is also very similar um it's a network idf1 so this this application i'm going to deploy to mainnet directly i'm not going to use the on testnet so everything is going to be on my net um this is a truffle provider of how many days uh configuration that is required so squared its initial uh npm install takes uh some time meanwhile what i can do is uh in this application you guys saw i need to have two kinds of assets right yes 721 and also a die so let's go ahead and see how we can get those right so how many we have a bridge to ethereum uh uh one instance running on the main net and another instance running on the testnet um to save some time i already uh braced two assets um let me go ahead and click my transaction i raised the die from e3m to harmony so yeah this loading of these links may take some time because i'm also live streaming so this is the die uh that exists on ethereum and there is a one die that exists on harmony um yeah so and i also needed a nft or erc721 so uh what i did was uh i purchased the nifty gate to a nft and uh i braced uh into harmony so this uh exists on both harmony and uh israel so quickly uh this is a harmonic ethereum bridge which you can use to send any different kinds of assets like erc20s coins and you can send how many native tokens like hrc20 and one token to the ethereum side and also this which allows you to bridge nfts like yes 121 and also the native heath um let's see if this is complete yeah um so next step is we have to deploy the lending smart contract right so uh for that i need i also need some configuration uh environment basically so i'm going to just simply copy the environment here let's do triple migrate i'm going to use harmony travel provider hopefully let's let's see if it works okay it's compiled and it's migrating shouldn't take more than few seconds yeah few more seconds uh starting the migration so what happens is after we deploy the contract we have to initialize the lending contract with the fungible asset that it will be used as a collateral so in this case it will be die so the contract is deployed and this is the fungible asset that exists on uh it's a die on harmony that we recently built so you can go ahead and check this one okay if i go to the explorer of harmony and put that address you see that it's a dice stable coin that uh was recently braced to hammon so once we do that now the contact is deployed uh as i mentioned this project came up with a nice client uh which we are going to uh and can install here once this should be pretty quick so what i'm going to do is initially show the application and then show the changes that i had to make in terms of the source code um [Music] this will be very quick get some water [Music] so i have about 13 minutes so yeah hopefully this will be nice so while this is happening okay let's see almost there okay uh let's see let's see yeah we're good so i'm going to do and build once and then start the application it will come as a browser application okay yeah yeah good to go and let's do yarn start so it's hosted in localhost 2000 yeah here is the application so it's automatically connected to metamask and it is showing a nice looking nft so in the metamask i have two accounts one is the lender and another one is a borrower so this lender you can see that i added a harmony mainnet configuration you can actually go ahead and look at that once it's pretty straight forward how many works on metamask right out of the box you just add network url and chain id that's sufficient so this lender you can see has one nft you can also look at this nft in the harmony one wallet i have the same lender under hrc721 you can see this nfte okay so the lender has this nft and now he wants to lend this nft so i'm going to click on this lend and i need to approve so metamask transaction confirm and let's keep an eye on what's happening here so after this approve it's going to ask me to set some of the lending configuration um yeah so i'm going to set let's say 10 die as a initial token worth and i'm going to keep it let's say one hour and i'm interested in earning three diet from the borrowers so i'm very expensive one but still let's go ahead and confirm okay a little bit slow uh let's confirm i think i popped up three transactions here but okay we can reject others that's uh fine okay so i was able to successfully learn let me reject other kind of other things that i okay so you can go ahead and see this uh set lending transaction on how many blockchain um you can see how much it costed right it's really uh very low transaction fees uh when compared to earlier i showed how much is costed in ethereum around 50 dollars um so i can go ahead and the application still has some glitches so i can see that i already have uh landed uh one nft so now let's go ahead and change the account here to borrower so i have several accounts here um meanwhile you can also go ahead and check whether the lender still owns the nft no he doesn't have any nft now so it's uh landed so let me go ahead and refresh this screen here so this is a borrower so now i can see that i can i bought it okay it's available for some borrower to borrow so i'm going to borrow um the configuration is loaded automatically so i'm going to allow [Music] okay similarly uh you can go ahead and check the transactions are pretty cheap to run on here so let me go back and here i had to initially it's a multiple transaction initially i'd approve for borrowing and then do the actual power away so this is one more transaction okay so now i can see that i have borrowed um and i can also check here that uh in my borrower assets i have this nft and also go to the one wallet and uh change to borrower and look at the hrc 721 yes i have the nft borrowed so now let's go ahead and change the account here to the lender and refresh this page um yeah in my land i can see that somebody has already borrowed my nft and they are paying me to die and there's also a nice message uh that if uh doesn't uh return the nft you can i can claim the whole collateral so let's go ahead and change this to borrower again and 75 minutes ago should be enough uh i in my borrow i am going to cancel borrowing allow transfer confirm so i'm basically returning the nft that i borrowed and i should get charged with 3d die in return so that will be paid to the lender so in the front end here you see it takes some time it's basically the front end logic uh the transaction itself is executed in two seconds and uh it is pretty fast so just keep an eye on here i should get back my dive um so you see yeah here you go i received my 10 dice back and if i go to the lender here i see three dice i add so that is a demo we have five minutes i'm going to go to the code here so and explain what else i changed to make this work right that is interesting as well so these are the uh simple migration travel stuff i needed uh uh i needed to write to deploy the nft lending contract apart from that i also changed the client a little bit so what did i change is basically here let's see in the collectible okay [Music] yeah what happens here is that that is this particular client refers to uh the openc where this particu nft was hosted if i go back here uh you can look uh the nft was hosted in the openc if openc exist was deployed on harmony uh we basically had to change nothing in this uh whole application since it was not deployed now i need a way to really map that nfd for that purpose i used when i breached the nft from ethereum to harmony what i do is i give my nft to a bridge smart contract on the ethereum side so that is what i am referring here uh find the collectibles of the lender in the bridge smart contract on the ethereum side and after that find the mapping of the particular nft so if you see here this is the contact address and this is the token id for this nfd this contact address does not exist on the harmony network so let's go and see what is the mapping for that address so if i type here the ethereum address you can see that uh when i bridged my nft it it was given a one one harmony uh nft address so that's exactly what i'm doing i'm trying to find the mapping using the bridge for that particular nft so once i find the mapping i can filter whatever in the lender page you see here right so if i go ahead and change this one okay this is under lender so refresh uh okay i should cancel and then i will get back my nft okay so meanwhile uh uh what else i did i need to change is uh simply add one more function that will filter the nft based on whatever i want so with these three functions uh basically that's it so if if openc which is an nft marketplace is deployed on harmony let's say then i basically don't have to do any of these changes then i i'll be able to look up uh the nft in the openc and able to get all the information regarding that entity so yeah so for the lender right you see the nft is given back so that is all i needed to change in terms of the code so let me go back to my slides so i have two minutes so i'm going to quickly different approached when we braced ethereum basically we wanted to uh get a bridge working on the main net and then slowly improve the trustless factor of the bridge initial deployed bridge uh contain a set of validators who will attest the cross chain events uh and uh basically when a user wants to bridge an nft or a esc20 they will ask this valid uh brace to perform the locking of the token on the ethereum side and after sufficient number of confirmations uh the bridge validators are going to perform the minting on the harmony side in the same similar fashion uh for returning the bristle token back to ethereum the user will request the validators to burn the bridge token and they are going to unlock on the ethereum side so we currently working on migrating from the validators network to a completely on-chain verification based bridge you can read more information here and i'm going to skip to my final two slides here uh gentle reminder that there is another talk by our ceo stephen uh uh if you'd like to know more about harmony and what are the some of the exciting stuff that's uh happening this year uh please tune in to that talk and we also have uh some bounties uh specifically five of them worth two hundred two thousand dollars each uh basically we want you to build uh applications that utilizes the bridge and one more uh project from the list of sponsors if you include more than one sponsor then you are going to earn more bonus points and that's it uh thank you for taking time uh come build on top of how many uh very excited for this opportunity thanks ganesh it's good seeing you thank you for the wonderful presentation thank you bye
Automatic transcript — names and jargon may be misspelled.