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

Loading player…

Mint and Tansfer Tokens the EVM Way & the Hedera Native Way - ETHGlobal Singapore 2024

ETHGlobalWed, Oct 9, 2024, 12:00 AM

Join us for a workshop with Ian Dilick titled, "Mint and Tansfer Tokens the EVM Way & the Hedera Native Way." Create a fungible token using Hedera Token Service. Create an ERC20 token using Hedera Smart Contract Service. Discover how these 2 services can interoperate. This is a hands-on session - all you need are a browser and a github account. This workshop took place at ETHGlobal Singapore 2024, a 3-day hackathon held from September 20 to 22, 2024, that brought 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: x.com/ethglobal Website: https://ethglobal.com Email us at: hello@ethglobal.com

Transcript

[Music] all right all good all right so hi hi everyone I'm Brendan deal engineer at hashgraph and um I'm here to tell you how to build on hadera so before we start just wanted to show you all the resources that we have available for you for this hackathon so if you go to github.com devader E global resources the link is in the E Global website for hadera um you'll be able to find this link and what we'll be doing today is this one the let's build section um introduction hia technology and hia ecosystem that's for you to read on your own time please go and explore that if you would like to so for now we're going to do this which is this tutorial over here so you can get to choose your own adventure and build tokens on herera in three different ways right so there is one way which is to use Smart contracts right um and that's evm compatible and then you can also use hadera native service called hadera token service or HTS and you can use that to build a token without using any solidity right just JavaScript Java or go take your pick so if you're a web two developer that's perfect for you and finally the Third Way is to build it using hadera um you can use a hadera token service um token and then you can interact with it via Hera smart contract Service so that's like an interoperability thing so I just wanted to have a show of hands here who here considers them uh considers yourself to be a web 2 developer right primarily okay and then how about who here considers yourself to be more of a web 3 developer so more in the evm side okay all right so with that uh I'm just choosing which one which one to do cuz you you can explore this repo in your own time and there's like multiple of them so you can explore all three and I encourage you to do so but for now um let's do the uh hyera token service way the N the native one so the first thing you'll want to do is open this in git pod so you just um open that in the new tab it's just a link and for those of you who've never used git pod before this is basically a cloud devel development environment it takes about 10 seconds spin up a fully working environment so I'm just going to make the font size a little bit bigger so that's easy for you to see and if you're familiar with Visual Studio code right um this is vs code but it's not an app on your desktop it's inside the browser right and it's all running on a Docker container hosted by git pod so it's really convenient all the dependencies have been set up for you so um just orientation here are all your files this is the code editor area and this is your terminal and you'll notice that there are multiple terminals you can ignore the all of them except for this one which is the main one now what the f what this is what is running over here on the screen screen if you can see this purple line right it's a script that's interactively asking you to enter some values to configure your accounts so what's going to happen is this end file has some credentials that you need you know to to get configured and get going and you know it's tedious so hence the script so seed phrase just hit enter for default and then number of account again you just want a few and then for RPC URL just hit enter and then for private key just hit enter and you'll use the first account that's generated from your seed phrase now just hitting enter right super easy now the next thing you'll want to do is copy this evm um address and then hold down command click and open up the foret foret dispenses harar which is the cryptocurrency and herera into the accounts that you select so let's paste that address receive your test net tokens and select on not a robot and then confirm transaction and within a couple seconds you should successfully sent so once you got this you can close the foret and you can come back here to the terminal and then hit enter and it'll just basically check the account whether it exists whether it's been funded and create a couple of other ones now once you've done this look at that I'm going to type y for yes and hit enter and you'll see the do end file update with all the credentials and you know it's just super easy and then also it runs RPC relay off the back of that so if you're doing smart contracts it's all set up for you now what I just did would take approximate maybe 30 minutes 40 minutes for first time H developer we just did it in about 2 minutes cool so now let's build something so what do we pick this now will we going to do uh the smart contract token or the HTS native token which one do we pick contract smart contract I okay raise raise your hands who wants to do smart contract version okay that's the majority okay let's let's go with that so the first thing we're going to do is open up token hscs right and we've got a solidity file that I've already written right so this is not a solidity tutorial right so this is a standard ERC 20 smart contract right with the code I've just copied it from a minimal implementation it's not open Zeppelin but it's functional and uh what we're going to do is compile that so I'm going to do CD into token HSS right so now we've navigated into this directory and I'm going to do npm run to remind myself what the commands are so npn run compile smart contract that just runs Soul CJs and you'll notice that I've got a bunch of new files here right and you'll see that I've got the ABI file and I've also got the bin file so this is evm bite code same evm bite code that you would get in ethereum or any other ethereum L2 and this is the ABI which defines the interface we don't really need that just just so you know that it's the exact same thing it's the same saly as what anyone else would would use um in any uh ethereum or evm compatible project so now let's run this script over here so script token hscs right and you notice here that I'm not using the herera um SDK right this thing here is VM right VM is a it's like ejs or web3js it's just another library that talks Json RPC and um what what we want to do is run this file so I'm going to do /script and then hit tab to autocomplete run that file okay so this has a script and it's running the script and it's pausing at every you know interesting point so if I hit command click and I'll jump to that part so it says okay I'm checking if the solidity smart contract exists so I just hit enter and it'll run the next thing now it's loading up the evm bite code and you can see the code for that so the reason why I do this is so that it's easy to follow along so you can track exactly which lines of code is doing uh doing what exactly right so this more of a learning thing you don't actually need to have the pauses if you don't want to right so we're loading up evm bite code okay so now we're checking whether the Json RPC endpoint actually is running right which is actually running over here right uh this is one of the tabs that in the terminal that you don't need to take a look at necessarily but this checks that it's actually running so it says okay it's live because I was able to get a block number and I was able to query the balance so all good now I'm going to do the first thing where it's actually significant I'm going to deploy the ABI uh sorry the evm B code right so this bik code that's over here this large amount of hexadecimals right that's going to go onto the hadera network now this transaction is a little bit heavy we're expecting it to take maybe um yeah maybe a couple of seconds there you go and what you'll see here is you'll have a deployed address right so let's go and hold on command and click on that and what we have here is Hash scan right which if you're familiar with ether scan is something very similar but it's just a hder version of it so we've got a smart contract here and we can see it's B code not very useful just good to know that it's there so then we go back here next step is to verify the smart contract right so this uses sortify um as it's underlying API in case you are familiar with that I'm just going to hit enter and it has verified so it says I've got a verification status of perfect which is what I expected so the next thing I'm going to do is submit the evm transaction to transfer token balance but before I do that I wanted to to come back to hashan and refresh the same page the same URL and this time we see that we have got the B code but now we've also got the source code right so whatever I have inside my solidity file over here right that same content are over here and not only that we have the ABI and this ABI is interactive so you can just fill in whatever the values and run the functions that you want um quite similar to Ether scan just a different um format in the UI Okay so now let's um let's transfer some token balance right so this is um you'll see here client. write contract we're interacting with this smart contract that we have just deployed which is happens to be the erc20 token hit enter and it runs this uh bit of code and after a couple of seconds or so we get a transaction and we can see over here let's open up that hashan URL in a new tab and we can see that there has been a token transfer that has resulted right uh and the way we know that is that we have a transaction log with shows you transfer signature hash from to anount yeah same pretty much same thing as ether scan okay so now we're going to query the token balance right so so far we've dealt with transactions but RPC you can also just use it as a read um method so the code to do it is identical to how you do it in any other evm chain right so you do client. read contract this is a VM function call and we're just calling the the balance off function and let's do that and we get a result instantly so 100 is a balance um n is just JavaScript notation for big integer because un 256 is bigger than uh what is it 2 to^ 53 which is the max allowed in JavaScript so hence big number so you can ignore the N basically it's just 100 units as expected okay so one interesting thing that I'd like to point out is that this um thing is designed as a learning experience so what it does is every time we go to one of these purple lines um over here not only does it um pause for your learning ability right it also tracks when that gets done right so when it gets tracked so then you know how long it takes you to do it so let's take a look at the summing Matrix right over here we have whether you've completed the task and this one is interesting right let me just make that a little bit bigger so it's easier to read um time to First task completion so this is time to hello world right so it took a total of 7 minutes and 20 seconds including my time spent explaining things right um and time to um I I would say that actually includes the time taken to do the setup script and everything else right um if you just want the task itself just the the hscs token deployment that took us 3 minutes and 30 seconds right so what I want to point out here is that you know on herera a it's e compatible you can use VM you can use Json RPC you can use you know um the same solidity smart contracts the same ility compiler everything just works out of the box and everything all your skill sets that you have as an ethereum developer or any other evm chain developer uh development you can just bring it across the second thing I want to point out is that is actually pretty fast right so if you use this tutorial right you can actually get productive uh building a token in you know under 5 minutes um and including setup about under 10 minutes so hope you build on herera and I hope you also um try this tutorial and if you if you thought that that was easy right you can try out the hadera token service one which is this directory over here right um this one does native tokens I don't have time to go through it right um but it's a pretty similar flow right and it's actually even easier than doing it using solidity smart contracts finally there's also this is more advanced right token interoperability so this is one where you do a hadera native token and then you interact with it VI Json RP so you're kind of mixing or interoperating between the evm world and the hadera native world right and I think that's pretty fun as well uh it's it's a bit Advanced uh but you know uh it's it's it's actually quite fun when you understand what's going on under the hood all right um I will end the live demo here um I strongly encourage you to all check it out and try all three of them um you'll find me at the booth the whole of today and tomorrow so you will be able to ask me any questions if you want about hadera development and and I'll also just highlight that we have this other repo right which I've uh got on screen now with all the other resources um what we just covered here is the let build section so please have a read of the others if you want to have a more general knowledge about what herera does okay I think we have time for questions does anyone have any questions all right well while you're thinking of some questions what I might do is I might show you the hadera native token and you know if we run out of time then you know so be it all right let's do some let's have some fun all right CD do dot token um HTS all right and then I'll run the script so this time I'm just going to run through it with less explanations right um so this one over here you'll notice that we're not using VM we're using the hadera SDK now this is the npm or JavaScript version right it's also available in Java and go right so you've got three different so whatever flavor of language that you are familiar with you can use it right and you don't have to learn solidity so this this token that I'm about to deploy does not use solidity right so let's do this I'm going to configure a new HDs token so remember all that solidity code right this is the equivalent JavaScript code that I'm just scrolling across in the screen that's literally all there is that gives you a fible token like from here here to here right that's all you need yeah okay so let's run that and then I'm going to submit the transaction and then we will see that we have a token right now you'll notice that this token is not a smart contract it is a Herer native token so it behaves slightly differently but you can still see it on hashan now um we can also do token Association which is something that is inherent to herera I'm not going to explain it cuz in lack of time and then we'll submit that transaction and then now we're ready to do a transfer right so hadera you need to do Association before transfers it's like an opt-in system um kind of like similar to the allowance system in erc20 so let's configure a token transfer let's um then submit that transaction and what that does is it transfers the token from one account to the other and you can see the transaction for that um since this one is a a native token it renders differently so you can see an additional section here called token transfers and you can see that um you know from this account to that account um and then let's take a look at summary metrics so we can see here that this time we've completed two of the three tasks that are available here right and the total time that we've taken for everything so far is apparently 12 minutes and 39 seconds right so that's not bad we have deployed a and interacted with a token on a smart contract Service and we've also done it on the native hadera token service and the entire thing was done in under 15 minutes including configuration installing prerequisites and everything so yeah developer experience productivity that's really important to us and you know I hope that you enjoy working with this repo all right so we've got two demos I was only expecting to do one um now do we have more questions yes comp with tool for the other toolkits for the DFS what's an example of a toolkit scaffold e like scaffold E from Austin Griffith um it's compatible in this yeah is compatible in the sense that you're using uh let's say VM or ethers JS right so that would work out of the box but in terms of like whether it works with I think it I believe it uses react or or yeah so that stuff is sort of secondary it doesn't really matter what you use so in theory it there there's no reason why it couldn't work it's just that you have to figure out how to sort of join them together ah okay I get I get where you're going with this okay so that is where interoperability comes in so if you want to have an ethereum tool or framework and work with the hadera native tokens that is possible right so the first thing is you I'm assuming that you're going to be using an evm compatible wallet right like metamask for example right and that operates entirely using uh evm addresses Etc so every hadera native token has an alias as an evm address and you can just interact with that then you can use the code that you find inside of here right and you can you'll notice this this actually interacts with the hadera native token but it doesn't do so via the hadera SDK it's actually using VM right so this would be exactly what you're asking about yeah so you're you're looking at the more advanc thing um but you know I'm prepared yeah just don't have time to demo it today cool any other questions all good amazing Okay so um if you do think of more questions or maybe just a bit shy um you can come and find me at the booth um the hadera booth in the main hall remember when you first came out were private that right okay so it has an interesting uh history in the sense that when it launched right the white paper was about hash graft which is just a consensus algorithm in and of itself with dat a blockchain attached to it so that's hash gra and then they added hadera as a blockchain application which uses you know uh hash graph as a consensus algorithm so maybe that's what you're referring to and yes you can use hash graph for both private purposes or a public blockchain which is what H is I wouldn't say yeah uh yes and no it's a bit Nuance but yes right now it's only public but yes it could be private in the future in fact there are some projects that are trying to do that but yeah watch the space yes last one sorry I do not believe so no no I okay so this thing over here hashan right um is a UI representation of A Mir something called a mirror node API which is our own like it's a specific kind of index service if you like so it's like a web to rest API style way of quering the data that's on here so you can think of hashan as a UI wrapper around that API cont yes um you you would be able to see it like here for example but it wouldn't have those specific kind of queries that I think you are talking about no yep okay I I think we are out of time so if you have more questions come and find me at the booth [Applause] [Music]

Automatic transcript — names and jargon may be misspelled.