Build Ethereum Web3 apps quickly using the latest tools by Anastasia Lalamentik


Video Transcription

Hello everybody. I'm Anastasia la Lament. I am currently in Raleigh, North Carolina. I'm with Kaleo. I work as a full stack engineer there. And um today, I'm going to be talking to you about building Ethereum web three apps quickly using the latest tools.Uh Just an overview of what I'm going to talk about. I'm going to start by describing what a multiparty system looks like. I'm going to go over some of the enterprise Blockchain challenges that are faced by a lot of people who try to build Blockchain applications. And then I'm also gonna touch on how Hyper Ledger, Firefly can take away some of the complexities that are faced by enterprise Blockchain. And then I'm gonna follow up with an example of three use case that I'm gonna use to illustrate how Firefly can um help with making everything more seamless when it comes to building web three apps. And then at the end, I'm hoping there will be some time for a Q and A. Um So yeah, let's get started. So what is a, what does a multiparty system look like? So in this example, we have a private Blockchain network consisting of five members, they each come with systems that need to communicate Blockchain back data to other members in the network publicly and in a lot of cases privately because um you know, sometimes member one just wants to communicate to number two or you know, not everything has to be public all the time uh in uh enterprise Blockchain.

And each member has their own stack of application user interface database, everything that is completely private and secluded from other members. Uh With that being said, the middle layer here, they still need to um agree on assets and data models so that everything can be synchronized across all their systems nicely. So stuff that is shared um you know, pe each me, all the members need to come to an agreement on how data would be um modeled. So that part seems simple, right? Um But what needs to happen here in this Pentagon, there are things like data and document exchange, uh private messaging, delivery and sequencing of events, uh tokenization of assets, identity management. And even more, these are things that are needed to support the needs of many enterprise Blockchain uh use cases. So um with enterprise Blockchain use cases, the majority of the data will actually live off chain for, you know, privacy reasons when a developer starts building out an enterprise Blockchain use case. Um The Blockchain part may seem simpler.

Uh The problem is actually in the off chain plumbing such as being able to sequence events properly deliver events. Um and other things that we've discussed in the previous slide, this problem really takes away the focus resources and time from actually developing the business logic.

Ideally, the job should consist of, you know, modeling assets and data defining the process orchestration, uh turning smart contracts to simple API S and then finally deploying it. But fortunately, there's currently an open source platform in active development that strives to take away all the off chain complexity that I had just mentioned. So let's take a closer look at hyper Ledger, Firefly. So in Firefly, you can do stuff like mint tokens transfer and burn them.

You can on board new members. Uh There's a lot of logic with event delivery and sequencing identity, private messaging broadcasting stuff to the network, um privacy privacy um features. You can subscribe to events in the network to trigger downstream processes in your businesses in your business.

And um with Firefly, you can really just write, you can really write 80% less code and focus on your actual business logic instead of trying to solve all the off chain plumbing layers here that frequently get, you know, the wheel gets reinvented with different companies trying to do the same kind of things.

Um So yeah, with this open source project, now, you can also easily turn smart contracts into API S. So smart contract developers they can publish to Firefly. There are smart contracts to generate API S that are friendly to traditional developers who are writing the core application logic developers who might not um you know, have Blockchain experience, they can still interact with the smart contracts through uh easily through firefly.

So now I want to walk through a simple use case of a consortium of players in sustainable fashion that supports supply chain tracking. Um So we have five members here. There, there's fashion brand, a fashion brand B con supplier, one con supplier, two and an Ethical sourcing Association um which I don't know an an entity that researches cont suppliers and rates them based on how ethical their uh cotton harvesting process is. And everyone in this consortium is incentivized to act responsibly, right? Because cotton suppliers want to strike deals with fashion brands, they want to maintain a reputable rating from the Ethical Sourcing Association. So they have to make sure that um they do the best they can to ha to be environmentally friendly and ethical uh fashion brands also want to pick the best cotton suppliers to work with because that also affects the general public's view of their brand. Um They can also with, with uh this use case, choose to link, be able to link a clothing item back to a specific batch of cotton harvest. Provide consumers with a platform to check where their shirt came from. They can also choose to transact with the um Ethical Sourcing Association. Um If they need specific research done on con suppliers. You can get really creative with the use case. Uh But I'm just going to pick a few examples here for my demo. Oh lastly, yeah.

So ethical sourcing associations can use um can use tokens to award certifications to con suppliers and with um by using tokens by minting tokens uh non fungible tokens that has a data attached to it, which the data could be the certificate for being, I don't know, child labor, child labor free or uh being efficient with their water usage.

Um But the point of the non fungible token is that, you know, a fashion brand can trust. Um cotton suppliers claims about being like GM free and child labor free since there are records of ethical like the Ethical Sourcing Association minting Tokenized awards to cotton suppliers on the Blockchain. Um So they don't just have to take the uh uh con suppliers work for it.

There's a proof and it's guaranteed to be authentic. Um And yeah, we minted by the Ethical Sourcing Association. So let's keep this example in mind. Um And here's what we're actually going to run. Um I will set up this, I have Firefly cli downloaded to my computer and I'm going to set it up for local development. It uses Docker compost to run all of the components. Um We would be spinning up these things called super nodes, which pretty much includes all these different components that we touched on earlier. Um And so now I'm going to, oh actually, I have another diagram here. Great. Yeah. So there's a token connector, Blockchain connector and you'll be able to see that more clearly in a second. All right, great. So, yeah, so this is the Firefly Cli. Um This is all open source. You guys, you all can um try this out on your own after I can send some documentation for anyone who's interested to follow. Not right now, but maybe at the end. Uh So yeah, so first off, this is the Firefly cli it's a developer tool used to manage the local development stack.

Um So what I'm going to do now is to replicate my example earlier, but maybe with just four members, I'm just going to have fashion brand, a fashion brand B um just one cotton supplier and the Ethical Sourcing Alliance Association. So here I'm going to in it, initialize a stack. I'm going to name it demo and like I said, I'm going to select uh just four members. It's been up four members and I'm going to start that. So in Docker, this is gonna take a little bit of time, but you can see here that in Docker, there's some stuff being spun up some containers um that you'll be able to see what they are shortly. So this is super developer friendly. There are, there's a bunch of documentation on building Firefly if you're interested later. On to try this out on your own. Um But let's see here. Ok, so I can now drill into what's inside of this uh Docker compost. Um So we have a bunch of different containers. So we have four members and each member has their own uh microservice for all the different things running separately. So that's how everything is separated. We're like um trying to mimic the real life usage of uh cotton, cotton suppliers, having their own application running uh fashion brands, having their own application running and same thing with the Ethical Sourcing Association. So there's zero member, zero, member, one member, two member three, that's four.

Each member gets provision, a token manager, tokens manager, E connect IP FS which is the shared storage system, data exchange and then a sandbox is a, it's a really nice way for uh everyone to be able to um easily get examples on how to use the API S that are made available.

So let's see if this is ready. OK. Not yet. But I'm gonna, I'm going to, whenever that's done spinning up, I'm going to use these four different browsers to illustrate the different participants that are in the network. So for example, the red one, I'm gonna call this FB one for fashion brand one. Um The pink one is fashion brand two. The blue one is the cotton supplier and the green one is the Ethical Sourcing Association. So let's see now if this is done. Perfect. Ok. So now um each, each member uh in Firefly. Oh, sorry. It's not completely done. It's still registering the org and note for number three, but I think. Ok, great. So now it's done and, and Firefly spits out the all the end points for each of these things. So the Firefly U I as you can see here, um this is for number one which is the fashion brand. It also comes with a swagger api definition that you can easily just like try out all the A PS with. And then there's also the sandbox which is here. Sandbox is the place for um is what I'm going to use to demonstrate the use cases that I touched on earlier. So let's refresh everything to make sure that we are starting from a really clean slate. Oh, I have been done that yet. So that doesn't exist yet for now. So let's see. Then there's the fashion brand be here browser, ok. So let's briefly go back to um one second.

Oops, let's briefly go back to my example here uh with the web three use case. So fashion brands want to pick the best rated cotton suppliers for their products. Cotton supplier sends ES A and fashion brands information about their cotton harvest for transparency, es A reviews this information and rate suppliers over time. So let's start there. And um so I chose the cotton supplier to be this blue one. And actually before all that, I want to quickly introduce the Firefly U I and um kind of give everyone an overview of what, what's um what we should start out with. So in the network tab, you can see the organizations uh they're not name according to my example, but Org Zero is fashion brand A B and then con supplier and the Ethical sourcing alliance here. You can see all the members that are in the network. Um They, they each get ad ID, which is a decentralized identifier. They get an ORG ID and um some other identities like note identities that are going to be used in the Blockchain transactions. Um And then you can tell which node you are here through this purple button purple, you are there and then let's see, what else should I show for now? Oh OK. You can drill down to what your note consists of.

So like I shown briefly in the Docker and Docker here, you get an Ethereum Blockchain component, you get a database, there's a data exchange component, there's an identity component, share storage and tokens. Um And yeah, so that's just a brief overview of what's here before we start putting stuff in here. Um And then next, going back to the example that I had highlighted earlier. Um Let's start with sending a broadcast message which means um all parties in the network will you know, get this message. So let's just say hello, this is cotton supplier one. And I wanna tag a message, I wanna tag this message with uh the attack and basically indicates the purpose of the message so that applications can process it. So I'm I'm just gonna say introduction. Um and hello and here you can see the events come through for each, for each uh different member. So that's how you know that everyone's got gotten the broadcast message. So that's great. You can also send broadcast messages um with different formats, JSON or even in file format.

So next I want to um send I'm I'm now with the cotton supplier and I had just gotten my first harvest of the season and I want to tell um fashion brand, fashion brand A which I am actively working with about like my most recent cotton harvest. And I also want to um send that information to the Ethical Sourcing Association so they can do some research and rate rate, like rate my um uh rate me as a con supplier. So the first thing that I would want to do is to define a data type. So this broadcast a schema for all parties to use when validating a message. Um So for cotton harvest, um let's see, I'm not very familiar. So I'm sorry if it's not accurate. But um so this is the J on the data, the schema that I came up with for a cotton harvest con yield. So I have an ID, I have a type type of cotton, P A Upland Egyptian, I have the number of bales of cotton and then I have the source or um information about where the cotton was harvested. And the purpose of the date uh defining a data type is so that all members in the network can work, can agree on what a data like this data would look like.

So that when they code up their applications, they can be prepared to receive this data in a specific way. Uh For example, when a fashion brand receives this information, I'm sure they would want to like start triggering some downstream processes on their side. Um And we'll elaborate on that shortly. So I'm going to define this data type. Oh and, and the main reason this data type is very useful is because uh when things are being, when messages are being sent um across the system, the data type validates if the message is uh valid or not. So we'll see that in a second, I'm gonna define this data type. I get a batch pin to the Blockchain. Everyone else also gets a notification that a data type was broadcasted. And now I actually want to um send the actual information, right? So now I'm the cotton supplier and uh and then um just to illustrate why how this data type validation works. So bill was supposed to be a number form and now I'm, I wanna be bad and just like put in some string and not follow the rules. Um I want to tag the message with new harvest and um let's see, let's make this type crema cotton. I'm gonna sign it some random ID and source. I just, I want to put Lubbock Texas. This is where the cotton was harvested.

And then like we said before, I just want this to be sent to the Ethical Sourcing Alliance Association and the fashion brand that uh is currently working that I'm currently supplying uh cotton for. And I don't really care about fashion brand B I don't want them to know anything about this information right now. Um So this is a private message and I'm gonna send this and this is great because I basically, I did not put this data in the right format. So now I have to fix that and I'm gonna put five bales. Um not sure how much that actually is, but let's run it. And now you can see that. Um So this is fashion brand B and they, they know that there's a Blockchain event that just have occurred, but they can't actually see the message um as opposed to fashion brand A, they received a private message um about and it's tagged as new harvest. Um And pretty much you can go here on the Firefly U I and see that um see the message that was sent by um con supplier one and um Just to confirm that fashion brand B cannot see that. Um Yes, you can see there's no private message here in their timeline as well. So yeah, that's how private messaging can work on Firefly.

And then I'm gonna describe, I'm gonna describe what would usually happen when um you know, uh applications, member, applications like the business applications to receive these events, Firefly with Firefly, you can just subscribe to uh events through a web socket and you'll get exactly this.

So as you can see this event came through a few seconds ago and um just to illustrate what would happen on the I don't have any code examples for this. But from a from a fashion brand perspective, when they get an event that says new harvest P A cotton, they can now trigger some downstream processes. Meaning, oh, we know we now know that five bales of cotton are coming. We need to um save this information to our database and and make sure that the warehouse is cleared. Um We need to start preparing for new production. Um And that's all that all could be, you know, expressed in code in some way. Um But I'm I just want to illustrate how the events um delivery here would be a really uh nice feature that enterprise Blockchain companies don't have to build independently when they use firefly because this part could get um annoying, especially with the with enterprise contractions.

You need to be able to sequence um things properly. And if anything is out of sequence, you know, things can go, can go wrong very quickly. Um So there's that and then additionally, the other party, which is the Ethical Sourcing Association, they also get a notification here, an event here that new harvest um just happened. And then from their side, they're running a totally different application. They're processing the exact same, same data that gets sent to um fashion brand A but in their case, they want to start uh getting people to do some research on this location and, and making sure that no child labor was involved or um you know, every everything is organic and not GM free.

Um And yeah, their application could just be waiting for this tag trying to read this tag um to, you know, start uh carrying out actions on their side. So that's examples. Those are examples of how messages would work in this multiparty system. And then um next, I'd like to move on to tokenization. So like we talked about before the ethical sourcing, all uh association can um can tokenize certifications for cotton suppliers that they are recognized to be like gray or GM free for 10 years or something like that. Um So a way to do that is they can create a token pool and, and I'm gonna choose the non fungible type. So I'm gonna name the pool name GM free and use the pool symbol GM three. I'm gonna create that Token Pool first. Um And then um let's say that I want, I want to award um cotton supplier one with a GM free and sustainable award. I can broadcast, I can mint a token and broadcast a file attached to the token and see here like proven track record for being pesticide and GM free con supplier. One. OK, great. So I have that and then I can tag this uh as a word and the topic could be GM free and a topic associates a message with an ordered stream of data.

So um it's just a nice way to like timeline wise to see how uh data is coming into the Blockchain. So I'm gonna, I'm gonna mint this token for um actually for myself right now because I want to still be able to control the certificate just in case in the future um con supplier, one is no longer as problematic or uh they found out that they lied about some things and the certificate is like annulled.

Um So, so I just minted a token for them for uh that has the data, the certification data attached to it. And now I can me as a fashion brand. A I can go to Tokens in my Firefly U I and then I can browse the pools of token. Now, I can see that there's a GM free uh token pool and I can see that something was minted uh token index one and I can see the message ID attached to it and I can see what exactly it is. I can download here and see that it's a certification for con supplier one that was released by the Ethical Sourcing Association. And that way they can be confident that this is not fraudulent. Um um because everything's on chain and you can verify that, you know, it's authentic.

And then like uh going back to the scenario that I mentioned before because I'm minting this token to um and because I never transferred this token to cotton supplier, one, I um I can, I still have control over it. And let's say that in the future uh the this ethical sourcing association discovers that um the con supplier lied about something they can just choose to burn the token meaning it's no longer valid. So con supplier, one lied about being GM free and then I can tag it as a word N GM free. And um and then for example, fashion brand A also gets that event and on their business application whenever they, when, whenever they get an event that has this tag, they can, I don't know, choose to immediately stop working with the cotton supplier, um whatever they want to do, right?

So, um and all this, all these are um packed by Blockchain, they're pinned to the Blockchain. So um you know, as you can, as you know, Blockchain is immutable, you can't, you can't change the data. It's guaranteed to be, um, you know, trustworthy in terms of data wise, like there's not a malicious, it's hard for malicious agents to try to modify data that's already in there. Um So that is another use case for uh firefly. And then now I'm going to kind of stop using that use case and try to um show you, show you all the other stuff that uh fireflies made available. But I don't quite have great examples in mind for right now. Um So just now I showed you um minting how to mint uh fungible, non fungible tokens and attach data to, to it. And now I also want to demonstrate that you can also um mint fungible tokens and transfer them around um to other members. So I'm going to just follow this example and first create a token pool for the fungible token and just to make sure I don't have any questions so far from anybody. Uh Let's see. OK. Nothing yet. OK, great. So going back to this, I minted uh I defined a token pool, created a token pool and I want to mint 1000 acne tokens on it. And um now I want to transfer it to other members in the network. So let's see.

I wanna transfer this to organization zero and send 50. And here you can see that as organization zero, you can see that you have tokens in your wallet. Now um transferred by the other member. So that's pretty neat. And yeah, so those are the token functionalities that Firefly supports. And lastly, I want to move on to the more exciting part which is the uh deploying smart contracts and turning them into simple API S. Um So I'm going to start by uh showing you which showing you the solidity contract that I'm going to use. For example, it's a very simple one. It's called simple storage and it's just setting and getting uh uh a value, it's just a storage of the value XX. And um we're gonna turn these set and gets into a simple API S that can be accessed by any traditional developer. So the first thing that you can do is to, I've already installed a solidity compiler. Great. So next I have to compile the smart contract and turn it into A B I form it. OK? So now I have a simple storage, Doc Json A B I that I can look at here and gonna format that and I, I can take this A B I and register or not register as in uh oh no, I first have to skip the step.

I have to deploy the uh contract first and this is just locally simple. Oh, no, thanks. Oops. Sorry about that. That is, yeah. OK. Don't need that. OK. So the, and our stack name was demo and then I have my simple storage storage dot JSON. And now I get back an address for the smart contract and now I'm ready to define a contract interface. So uh there are two types of interface formats, firefly interface and solidity application, binary interface, which is what we just generated uh firefly interface. Since uh firefly works with fabric and Ethereum. It's just a generalized way for um firefly to understand if it's uh understand what a, what API S they're supposed to spin up. Um So fabric chain codes look very different than uh solidity code, but the interface should be um it just tells Firefly there's a way to construct this interface that I'm not gonna touch on at this demo. But uh I just want to briefly touch on what that is. So I'm gonna switch over to A B I and then I'm, I'm going to go back here and copy this information and name this simple storage and this is the first version. So I'm gonna run that first version. So now I have a contract interface confirmed I can register the I can register the contract API and take that contract address that was generated after deploying the contract.

And if you pay attention to this here, now we have API S known to Firefly simple storage and now you can easily uh just interact with the smart contract using um using the simple API S, right? So everyone, each one of the members, actually, I'm going to switch over to another member just to show you that uh they also are able to access the smart contract. And I'm gonna be this blue member and I'm gonna assign a new value to um to this simple storage, I'm gonna assign, assign it to 100. And then if I go back to this red member and um check the value of the, the value that's in the smart contract, I can see that it's been updated to 100 just to do that one more time. I realized that I didn't show the original value. So I'm going to change this to 50. Now execute that new value is 50 and now it's also 50 here. And lastly, I want to show the contract listener. So there was a um so for each member, they can register a contract listener, meaning um if the value change right now, there, there's just one event in the smart contract which is change. So I can choose to listen to that.

And now if the, if I change the value here, see if I can make this smaller, you'll see that. Um Yeah, you get an event that says that the value has been changed and you also get an event here. Um Pretty much describing the the event change, the value of the change, uh simple storage X value. Um But yeah, so this is specific to each member. So each member would have to register their own contract listener. Um for example, you can't see that event here because this member never um subscribe to that contract listener. Uh But yeah, all this everything I had just shown you, it's and even stuff that is shown in the Firefly U I that you can, you can get all that information uh through this API and I know I just showed everything locally but, and um so, and so a lot of people like to ask like, what's the um how do I go to production with that?

Right. So that's where Kleo comes in. Um You can have a live environment of everything I had just shown. But through Kleo, you can have live nodes um hosted on Kleo, you can spin up your, your own, your very own network and um their configurations that you can tailor to your needs. And um yeah, just start connecting to the Blockchain notes through your business applications the same way and have access to even all the U I that I just sent you, you can access that through the Kaleido console. Um So if the demo and everything that you had just seen um interests, you uh it's an open source community, feel free to join the conversation on Discord or uh join the activity on github, start contributing um giving feedback and participating in discussions on Discord. Um And yeah, that's all that, that's all I have for today. I hope it was interesting and helpful. Uh feel free to reach out to me. I'd love to um you know, talk more about our discussion today. Uh If you have any questions or anything, let me know. I know I didn't leave a lot of time for um, oh, sorry, let me stop sharing. Ok. I know I didn't have uh leave a lot of time for questions. But yeah, let me know.

Um, if you want to talk outside of um the session, I see some, I see some questions here. Let's see. Um Sorry, I have to scroll up a bit since I haven't seen this. Are there any gas fees or any other costs when developing an ex and experimenting? So, no, there's not. Um like, like you've seen me spin up, like I, I spun up everything locally and with no um you know, connections to real Blockchain so far. So there's no cost at all for developing and experimenting. Um And um what would you advise to traditional software developer who wants to get into Web Three and Smart Contract? Um Yeah, it's a little bit intimidating at first. It took me a while to really understand what's going on. But um uh I think it definitely requires a lot of reading and just trial and error. I, I, I think personally for me starting starting to build projects on web three actually helps a lot like reading, reading helps, but actually putting things into perspective and coding it um really, really like helps you gather really helps you understand things more in depth.

And um yeah, if you wanna talk more um connect with me on linkedin, I can give you more advice uh and resources. And is there anything else to learn more or uh the Fire Hyper Ledger Firefly site has all the information? Um Yeah, everything that I just talked about um would be on the Hyper Ledger Firefly. There's a discord that um let's see if I can get the link here, paste the link here. I don't know when this thing is going to close. So uh OK. One second. So this is a discord that you can join to um participate in discussions or ask questions. I would encourage everyone to try spinning things up locally uh Just to see how things work. Um And what else? There's a github as well if you really, if you're, if you're really interested in the code um that went into, you know, all that, the U I is really great, my coworker built it. He's really great. Um And, and you can also totally contribute to it. By the way, if you want to make it even more beautiful, it's open source. Um There are community calls every month I believe, but all that information would be on the uh hyper Hyper Ledger Firefly um website. So, yeah, that's all I have for today. I when is this? Um when are we gonna get kicked out of here? But I'm not sure, but I don't wanna um yeah, I just wanna thank everybody for the time and um again, connect with me on linkedin. I'm actually gonna past my profile here.

I hope it was useful and um I hope it inspires you to build your own weaponry applications. Uh You can get really creative with the use cases as I've mentioned before. So yeah, I think that's all I have for today. Um Yeah, feel free to reach out if anything. And um yeah, thank you guys again. Have a wonderful day and enjoy the rest of the conference. Take care.