 So, welcome to this Hyperledger Sweden Meetup. My name is Roland and I'm happy to be a guest for today, for this session. And today I think I have prepared some awesome content for you. We will extend the network from the last session. So, based on this network, we are going to discover how we can use chain code and smart contracts. And this indicates our favorite version too. And in my presentation, generally in my slides, I will show you not only the theoretical part, I will show you also how you can do this, how you can, how it feels. And I will give you also around this topic information. And in the first part, I will tell you something about the term smart contract versus chain code. And when we come from a technical side, we sometimes we forget what about in the field before when it comes to the chain code. And so the term smart contract is a little bit different used in Fabric. But when we read carefully to the documentation, we will see that they have linked this term to some specific context and chain code also to a specific context. But we will see this a little bit later. And then in special, we are going to discover the new decentralized governance for chain code for smart contracts, which is introduced in the version two. And to see a little bit of the difference between their process, we have to do in the version one. So in Fabric version is 1.4, 4.6, or 9. And in the comparison to the version two, so we can see a little bit how this process differs and how we can, which steps we have to do. And yeah, and especially in this session, we are going to the chain code lifecycle management and see what is this for. And to practice this a little bit, so I have prepared a chain code for this. So in this example, we are going to use the test network as well. But we don't use the standard chain code, which is ready for it installed. We will use a different chain code. This is called the AB store chain code. It's also in the Fabric samples. And so with this example, we can see how we can use the test network to use a different chain code. Of course, also your own chain code when you try to test it and try different things. And it is the reason why I have decided to do this. And then we're going to install this in our both organizations and see how this works. And then if we have time enough, then we can modify this chain code because the guys from the business for the management said, okay, we have to change our smart contract because we want now different rules in our organization or in our network. And then we have to formulate this and then we have to up change the chain code. So and then we can see how is the upgrade process for the chain code, which we have used and installed before. And here you have the references. But as I have mentioned in the slack, not in a slack in the, in the zoom chat, I have copied the link to the slack channel. So please join if you doesn't, then also the link to these to report to the GitHub repo is there. So you can now copy and paste. If you want to do it with me, then you can copy and paste the commands directly from the GitHub page. And the slides, the slack channel, you can see the slack channel in front and if it's not working. So I will do it later. And yeah, and of course, the documentation is for every time a good resource to read. And that's the reason why I have it here. So, okay, so let's come to the first point smart contract versus chain code. And that's an interesting part. So many people think blockchain is a brand new technology. So, but it isn't, I think so. When we say Nick Chavo or Nick Sabo has introduced the term of a smart contract in the paper called smart contracts, building blocks and digital for digital markets in the 1990 1969. So, and this is a paper where today, so I read the paper published two months ago about smart contracts. And also in this paper, this article is used and so smart contracts exists a long time. And also other technologies which are used in fabric and blockchain technologies are not new. So only the combination is new in this field. And this new combination makes this blockchain technology so valuable and gets so much impact because these are techniques which are proved over a long time. And here we have a small diagram. So, and we have an organization one and we have an organization two. And we have to terms smart contract, and we have to turn chain code. So how we can differ this two parts from each other. And I think so that's a trial from my side to give an explanation for this. So, and I think before we can create a consortium of fabric network so as you know fabric is a permissioned blockchain system so this is not a public system. The most organization must come together and say, okay, we will create a consortium. And in this consortium, we have to agree to certain conditions. And as I have mentioned in the last session in the field of blockchain, there are a lot of professionals involved. We have seen the blockchain developer front end developer system administrators from the technical side, but also from the business side. So we have the business people and the managers and all the sales guys and who are going to do something crazy and cool stuff. And they try to implement and conditions so they say okay, we can come to an agreement and we call this a smart contract and this mark contract should be executed when certain conditions are met. And this we can call this the business model. So we can say a smart contract, you can match in the smart contract as a business model, formalized by business guys by the management, for example, and they discuss this and say okay, under this conditions, we come together. And the last slide you will see the business model from the AB store and how we will change it when the business guys say okay, now we would like to make a change in this model. And so we can say okay smart contract is like as a business model for this. And what you can see in fabric is the chain code and we can we can say the chain code is a programming implementation of the smart contract or from different from several smart contracts. And in fabric you see it a little bit more I think than in other blockchain systems like a serial where you have only one language to implement a chain code or a smart contract. So, and the chain code in fabric is maybe an interaction with an API layer so the chain code doesn't access the ledger directly or the channel. So the interact with an API and then fabric, you have different possibilities to do that. So, in my example, examples, I use the language go for that. So I need the language grow and use the SDK in the one point version, there was the shim, there's a low level API, so we can use it also in the version true. But, and then version two, we have this current this new contract API API. And in this language of gold, but we have can do it also in a language of no chairs or Java. So, and you see the chain code and you can translate the chain code here in a programmable implementation for this smart contract. And this is maybe a little bit a trial to understand what is when we talked about smart contract, we can do it and say, okay, this is more from the business model in the business side. This is a this can summarize this a business model. And when it comes to a chain code, then we have an implementation of this chain code in a programmable code. So every chain code when we use go, it's a program in this program will be installed on the BS. And, but we can do it and go in no chairs and even in Java. And that's make make fabric also unique, because this is not so in not so possible in other blockchain systems. And here you can see in this slide as we have the organization one and two, and when they come to an agreement on the business side, because in the first step, the managers from organization one and two, they must say, okay, in this conditions we work together. So, and they have to write it down, you have to write it down also in the paper. So, and they must assign it on a traditional way, I think, so because that must be a contract. And this contract should also bind by law. And some people say also that a smart contract is equal to to a law. And that's the way where we want, but the implementation how we are going to implement this smart contract. This is then the chain code, and this chain code can implemented in different ways. So, and I think that's a good decision tree or tree where you can come to this topic and think a little bit of this topic. And this paper, which is linked here is also a good starting point to read about the beginnings you can say about the beginnings in the 1969 from smart contracts and now we have 2020. So, you see, it's a lot of time going away until when it comes from Nick Sable's ideas and visions to the point now, where we are talking about tranquil. And in the fabric version true, there is a new process, and they call it the centralist governance for tranquil. And I think that's a really good step, a really good boost for the enterprise level and for the control for more control that multiple organization can work together. And the main message in this decentralized governance is that every organization, or the event in the standard case, the majority of the organizations has to be agreed with this new chain code. And they can test it, they can check it, and in the fabric version to there's a process for this, and this is called this chain code life cycle management. And that's the main message your multiple organizations can to come and can, can come to an agreement on the on this parameters of it, of a chain code. And before it is installed and before it is used. And here are some points. Yeah, so that means that in our last scenario, organization one and organization two must agree to this chain code. They must approve it. So with a former step, so they must make some commands, and then they can approve this chain code. And in the step before, they must have the possibility to check the chain code. So, and that's also a step before that we can say, okay, we can package the chain code and send this chain code to the organization. The administrator or developer can check this can test this on our own system and show how this works. And so they have no control about what happened. And also in the upgrade process. So we will see in the upgrade process, when we update our chain code, we also have to approve this update process. There's simpler. There's also a simpler endorsement policy and improvement for private data collections. This is about we will not see today, but we will have an inspectable chain code package. And that's also a good, it's a very easy step, I think, so they use a package to package the go program and a file a meter file with some informations inside together. And we have one file one tip file, for example, that we can send to the other organizations. And we can start multiple chain coms on a channel using one package. So there must be some scenarios, we are going to introduce the chain code once more than one time on a channel. And this is also possible. To identical. And yeah, that's an interesting part. The last part here, the chain code package do not need to be identical across channel members. So this is one I haven't tried so but this would something a good point maybe for the next time. So I think the idea behind this is when we have installed chain code on two organization and one organization would like to have a little bit more information from this, then maybe a small part fix or a small valid input validation. So something, some minor changes, which is not, or has not any, has not an effect on a read write set from the lecture from the transaction, the transaction will be also valid, then you can do this. But how this work this, I have to discover. I have to discover, I think, yes, so but that's also, but that's an interesting part. So that would mean that we can change the chain code. So before, before the improvement from the other organizations for minor changes, maybe that could be in the documentation is as is, is, is it written that read write set must be the same. So it could be that we can implement the query function. And because the query function doesn't change the read write set so but I'm not sure so this is the point I have to discover a little bit. And here we will see the transformation process. So we have here two tables. So in version one, you have here the install the chain code on the peers. So I do have to install command and then you install it. And when you install the chain code. So as you know, we have two names of peers, I think you definitions of peers. So we have peer is not equal to peer. So we have the so called endorsement peers, and we have the so called committing peers. So and what is endorsement peer, what is a committing peer. So endorsement peer is peer, the chain code is installed. So you don't have to do anything. So the only thing you have to do is to install the chain code. Then you will have an endorsement here. And when you have only appear in the system with a giant channel, then you will have only committing peer, and this peer is only used for the validation of the, of the lecture data. And so to get an endorsement peer, the only thing to do is to install the chain code. And then there was the instantiation step. So with the instantiation, the chain code is created. And then we are ready to use the chain code. So with an invoker within query command. And, and here in table two, you'll see the four steps here. The first step is, you can package the chain code. So and the result of the package growth is, is a simple chart. And then we have an archive, a zip archive with the chain code and a file called meta.chasing. And in this file, there are some meta information about the chain code. You can install it on the peers and the process is the same. So when we install it, then we will have an endorsement. And this endorsement beer can, can be queried and can be do the invoke action to center transaction to the order and so on. And this step must be done on every peer. So until every organization. And then this is the new step. So we are going to prove step. So every organization must improve this chain code. And when we change nothing, this is like in the test network, the default configuration is means that the life cycle and the Rosman policy. And that's the name must have the majority and then we have the majority and organizations in the network. And when we have the the two organizations, then we need an improvement from organization one and also from organization two. And we can see how which organizations have improved this chain code. So there is a command where we can check the readiness of the chain code. And so we can see, okay, organization one has improved this organization two has improved this organization three and four hasn't. So and we see this and every admin or admin from each organization can do this. So to do this actions, you have to be the admin of the fabric network. So from from the identity side from the membership service provider side, you must and admin for this. And then you can commit the chain code. And this step could be done by every admin in the network. So that's not only limited to the organization one admin who has introduced in our case this step, every admin in this organization can commit this chain code. At this time, when the chain code is ready. And then, in our case the majority has improved this chain code, and then the chain code is ready and we can use it. And one important part here is that this is a good improvement. So here we can see two improvements. The improvement is that we have a controlled version, a contract process where we can roll out our chain code, and we can see okay, in my organization, I don't have I don't want this chain code. I don't, I cannot improve this. And that's why the reason why I said the smart contract came from the management side. So when we found the network and the consortium, we have to come to an agreement and which conditions we have to do this. And that's not only the condition how is the chain code, how the chain code works, or the smart contract should work. So also about the endorsement policy. And also come to an agreement about the endorsement policy, and also about the life cycle endorsement policy. But these are two different kind of shoes. So the life cycle endorsement policy is responsible for the implementation and for the upgrade of the chain code. And the endorsement policy is responsible for the process. And is a transaction valid. So we are some organization must agree. So this process is also divided in this in these two steps. And one important step to our improvement is here when we commit the chain code in this step. The chain code is is executed in a single Docker container. And this Docker container is built on this step. So when we commit the chain code, then we will see the chain code, the Docker container for this chain codes are built and ready and started for both organizations. So when we come before thought with with our first invoke or with the call of the in its function for the chain code, then we don't have a delay. So, and this delay was in the version in version one. So when we have the first, the first, when we did the first section, then we have a small delay until and this delay depends how fast the machine is and how fast the machine can create this chain code. This chain code container. And I think that's an improvement for for the for the daily work. So, and then we have a ready to use chain code. And then that's a comparison. So, and these steps on the right side, we are going to do now. In the in the first step. So we have to package to chain code. So that's a good step. So we have a single file and this single file we can spread over the network, and we can send it by email or whatever, how we can send it to the administrator of the organization. And I mean, so for the practical thing so when you have an organization so who is the chain code developer for this is the chain code developer a consortium a group of a developer from organization two organization free and they work together. So that's like every other software development process I think so you can make a bear programming, you can an audit process, or whatever. So, but from the chain code side which I know so chain code is not so huge program. So, okay, it could be complex and it could also be a large one, but in most cases I think it's the work for a single person, not for a group. So, maybe a group can I think this can coincide this can help, but we will, I think, in most cases, we will have a single quota. A single go at Java not just developer who writes in the end this chain code. So, and I think I read something like this also in the documentation. It's a best practice so that we can have one creates this chain code, and then delivers this chain code to the other organization, and then they can can audit this chain code so but this depends on your organization on the whole process on your project management and so on. So, so that's a little bit outside from this chain code for the fabric world. And then when we have this then the the admins and developers can inspect this chain code and say okay, it's okay. Yeah. And then they can install it. So, they have a command and they can install it and every organization has to install it on on on the dedicated peers, which they want to have in this network. And then the proof process starts, and in this approach process every organization must approve to this chain code. And, yeah. And then, when the majority is reached, then, as I have mentioned, then one administrator of the whole network can commit this. And the system is ready to work. So, these are the four steps. And, yeah. And here's the small overview. What we have seen. So that's the same network consortium from the test network. And we have here is the same setup as we have seen in the last session, we have one organization with the single rough based ordering system. And we have two are in two peer organizations with one peer SM endorsement peer or configured as an endorsement beer, and we have a letter here. In this lecture, we have one channel, the channel is called channel one. So, this fewer this this display here described here shows that you can have more than one channel. So, the link between the between every participants in this network is the lecture. You can you can imagine this in different layers. So the lecture is the ground for this. And on this lecture, we can have a channel, so channel one so but we can have different channels and different channels can have different access rights for different members, and so on. And on this channel, we have installed one train code. Or different chain codes to do something. And we will store the app store chain code in the version one. So, two important facts here are important. So, we have a label, this is the code so called label, we have a version, and we have a sequence and a little bit later we will see what does it mean. So, but the label gives you the possibility to say okay, we want to want to give our chain code a version number. And there are different possibilities to do this, you can do it as it like in the normal software development process, you can say, my version is 1.1.1. You have a free pair. So, where you say, okay, on the right side, the first number displays some bug fixes, for example. Yeah. And the second number will be a feature, a non breaking and not a non code changing feature, for example. And when we change the number in the front and we have 2.1. Then we will, okay, the two in the front signals us that we will have maybe code breaking changes for this. So, but you can also have a number like one, two, three, four, and so on. So, that depends to you. But we will have a sequence number. And the secrets number is very important for the improve process and for the commit process. And the secret number is a simple number, but it must be increased on every chain code change. So, and, but we will see this a little bit later. So, and that's the reason why I fear this to one and 2.1. So that we are a little bit aware of this. And then here, what the chain code, what the chain code does, so here's two main functions implemented. So we have one query function where we can query something. And we have a invoke function to send a transaction or to do a transaction. And we have an elite function for for for the, for the console but in my case I don't use this one, it's only for completeness. And this is the use case. So, and we have to use cases. So we have to use case standard use case. So when the organization one and the organization to come to an agreement and what I've the agreement in this chain code is a Any account sense and certain amount of money to be. And that means that when we have to instantiate we have to in it to initialize the system with an amount of money so we can say person a has 1000 and person B has 10 10 dollars or 10, 10 amounts of, of, of money or units of something. And when we, when we send some units from a to be, then we have to decrease the money from a from a and we have to increase the money complete. So, and that's the business decision, the smart contract here in this example in version one. And this is implemented this functionality is implemented in chain code, which is by default in the three examples involved. And later, when we have done the management came and say, okay. Now the business grows and grows and we want to earn a little bit money. And we say, okay, now we have a lot of transaction and we have a lot of transaction costs and so on. We say we want to earn something. So we introduce a specific account, a bank or something like that. And we want to, we want to calculate the fee. So in my case, I have 2%, I want 2% fee on every transaction, a sense to be. So, okay, that's not really a good example. And also the implementation is not the perfect one because in the chain code, I don't want, I want not so much change in the chain code. So that, so, so that we have to complicate the things. So, and we have only used integers for the calculation of the fee in the, in the, in the chain code. And that leads that the numbers are not so correct, but that's only a single example. So by your kind of stand, what is the upgrade process and it's not the example how you can cash up some fee. To the bank or something like this is only a simple example. That's what I have. In the moment found and change the chain code so that we can have a similar a little bit, a little example that we can see how we can do this and we can look also a little bit in the second chain code. So last time we have seen the chain code with the assets and the default chain code. And this is also an example from the favorite sample so we can look a little bit in this and see how they do this and how we can change this. And here, this, this is the second implementation for the upgrade process. So, and yeah. So, okay. So, so can you see my terminal is that I'm not sure when when soon shows shows me which terminal. What is displayed in there in the display. So can you see my terminal again. So yes. Okay, so now you can see. A terminal on the left side, and you'll see there. The GitHub repo, which I have prepared for you. And with this tutorial, you can try to reproduce this. And yeah, so that's the same installation like the last one. And, yeah, we have some we have already some work done. So we are one or two environment files, where we have prepared the environment variables. And I would like to show you how today a new one. So there is a script. It's called monitor docker dot shell. And this is a script, which came so which are from the commercial paper example here. And in this script. So I will look in this. We use they use a docker docker container, which collects the, the, the, the chain code output, and why did to do to the standard output to, to, to the, to the terminal. So with this, with the script, we can collect the container output from the, from the train code container and see some debug messages. So I have, I have done some, some, some debug messages in this chain code so then we can see something. So, but this is a good, good point. So to collect the output in a single in a single place. And this script is under the commercial paper example. So you can copy this with this command here to our working directory. And that's a new, a new thing. And I think that's also new. I haven't seen that in the 1.4 version. But I don't know. So, but I don't think I have noticed this because it stands also in the documentation and I have, I haven't seen this in the documentation from 1.4. So I think that's the reason why it's must be new. Okay. So, and then we have true organization one and organization two files. So these are the environment variables. As we have seen in the last time. And also there for the organization. That's the reason why we can switch very easily between this to organization. So what I see here one, one environment variable isn't set here. So we can do this. So we don't have any problems with that. Okay. Okay, so. And then another good hint from a site is when you try a little bit with the system. Sometimes it happens that when you start the network. The boot process breaks. So there will come an error quite like channel can't create it or something like that. And this is this is this happens then when we don't use the when we don't clear the network in a formal or in a correct way. When you play a little bit with that today or tomorrow and then leave your machine and come into this again to this position and try another one. Then make always sure that your first execute the network down script. So, and in this case. The script is very, is very well. So it closes our networks, it deletes all unused images, it deletes all volumes are used or not used volumes for this. And then we are, we can be sure that we have a clean system. And, but you can also use the two Docker commands. So, well it to know when you use Docker system broon, then you'll see here, stop all containers network and so on. So, can also make sure that this is, and also the same for the network for the volume. For the volumes. You can also lead the volumes and then reclaim the space. So that we have, we're not, we're not losing so much space. Okay. So, um, yeah, and to do so, we use our max session again. So that's also very comfortable so when you have. This already exists. So we're going to touch. And you see the city difference. So, in this panels. Your history is start. We can clear it again. And for those you don't notice so how you can switch between these panels. And there are some keys, key commands. So it's really worth to spend a little time to the max documentation. And on the internet, there are a lot of cheat sheets. So you have summarized the most common to max commands and, and they're really useful. So and, and to switch between these two panels, you can use this command, this key combination. So, and this is always the control and be so with control and be you you come in so called a command mode. And then you can set another command. And with different actions. So, and when we jump switch between this, we have to say control be cool. And then you'll see zero and more command be all panels got a number. Zero, and then you can jump. Okay, so, okay, now we have a panel study, and we have cleaned up our system. And now we can start a new network. And we, we, we use the test network, and we create the channel one with this command. If everything works, then we will have the network running, but without any tranquils. And we are going to install now our own chain code and do the step by step. You can go to the script and modify the script in a way that you can store, of course, your AB storage. You don't have to be behind. But we want to, we want to see how we can do this. Okay, so if Docker peers, we see Docker containers is Docker containers are running. And as I've shown at the last time, you can use the Docker compose command as well. And don't forget the Docker compose file is not in the same directory. So this is where we are now, where we are now. So that's in the Docker, there's a sub director it's called Docker, and there's a Docker compose test. And here you can see the log from this. And you can follow this up as well. But we want to see something new. And that's a new monitor script. Make sure that you have here here access rights. So we need here access rights. And then we can start the monitor script with the name of the of the network, the network name is ready for it. So, and that's it. Now we can switch to terminal to panel one. So the process for installing the train code. So make sure, as I've mentioned, you must be an admin user. So, and as we have seen last time in version two, we don't need a chain code a CLI container anymore. So the, the, the peer command and some other commands are installed as a binary in the pin folder. And so we can call the, the, we can do all commands directly from the command line, and we don't need any CLI container more. So, yeah, so, but, and how we can be an admin. And that's the reason where we have set up these environment files, and we can execute this with the source command. We have also seen last time. So, and you can use the web command as we have seen last time to see, okay, this is, we have, we have this environment variable set. And about the environment variables, this will be also a good session, I think. So, favorite is based on the go language. And they use Viper as a configuration management tools. And most configuration variables came from the so-called core YAML file. And we can override this core YAML file with this environment variables. So the question is, which environment variables are exists? So there is no list. You cannot find the list for this, because it's in the core YAML file involved. So, and, but in the core YAML file, the environment variables are not written in this way. So this, this, this, this kind of writing of this combination of, of TLS enabled. So the TLS, the property name is TLS enabled in the core YAML file, I think. And the rest here, the combination here, this is provided to the Viper configuration, which is used in Go. I think a standard, standard library where you can use, which you can use in Go when it comes to configuration and import from configuration variables and environment variables. So, and how this fit together? This, I think, that's also a really good session title, because I haven't seen any demonstration or presentation or something like this about this particular topic. So, and I've seen a lot of questions in the chat and in the hyper-literature chat and a Stack Overflow chat where people ask me, ask where you can find which environment variables are exists. And to understand how this configuration belongs to the core.YAML file, this, I think it's, it's good for the mindset and good for the understanding where you can look and how you, what you can use as an environment variable and in which, in which you can. So, but that's our story. So, yes, so now we are in admin. So, in the first step, what we have to do is we have to package the chain code. So, and to package the chain code, we have to install all vendor dependencies. So, and in my scenario, I have copied this chain code in the chain code directory here. So, and we have here the App Store and the App Store too. So, but now we go in the App Store, version one. And here we have the App Store. And we have the mod file and the sum file. And maybe we can make a short look into this. You can see here this. So, and the chain code is also good to learn. So, it's always a good idea to look into this chain code. Also, if you are not a chain code developer to understand how this, this work and how which dependencies are also needed. So, you see here this code is also based on the contract API. And we have here the invoke function, we have a delete function and we have a query function. So, the main function is based on every group programs, but from the functionality side, we have these three functions here, and we have one init function. So, for the initialization process that we can say, okay, we have an account A and account B with this set amount of money. So, and here you can see this is the chain code. And this is now the coding abstraction from the smart contract. When we follow the picture from the first slide, we have seen a written contract where we can you can imagine a written contract between the managers organization A and organization two. And then we have a program written in the language go. And this is the so-called chain code then. And, yeah, so, and this year, you can see the dependencies. Yeah, so the minimum goal goal 1.13 is needed. And, yeah, so you can see the dependencies on the init see here. So, and, yeah. That's this chain code. And the first thing what we have to do is now we have to load this windows so it's already done, but I do it that you can see it works. So, and then you see here the vendor you see here all dependency and now installed. So, and then we can switch back to our root directory. And for the chain code package process. So it's important to have the fabric conflict path environment variable set, but we have all set it already in the in the one file. And the package process is very simple. That's this command. This command is divided into so he'll see we have to be a command. So that's the reason why we were we have to make sure that the environment variable to the pin directory is set correctly. And this is one task we have done in the last session. So we can call it be a command as a binary directly from every position now from the operating system, because this this command is part of the path of the system path. So, and then this command will be found like any other command on the system. LS copycat and so on. And then we have here the command life cycle and chain code package. And then we have to give them a name. So we can give, in my case, this app store target set. So you have an target and and it's a target. So, and that's maybe a third party software, which fabric use to package his package to chain code. And then we have to say, okay, where the where is the directory of the chain code. And then which language used. So we use to go. We use it. So this labor is now starts to be important. So we will see that this labor is like an identifier that we can see. Okay, this is labor is one. So can identify with this. And to this labor, there will be later a hash value, which stands for their for their for the package chain code. And, but this we will see a little bit later. So, okay, so when we try this, then we will have here file. So we can look into this tar file. With the TFX command. So, and you see, two files in. You see this meta JSON file. And you see the code target set file. So then this code target set. Inside what I've seen. From the chain contract. We can expect with this code here. So we can make a short look into the web. And when you see cut. This. Yeah. And you. So you can catch this file. Then you will have this result. But we have installed as a helper tool in the last session check cool. And when we pipe this, then we can have here. A nicer output for the command line. So what is inside of this. So we see the type. We say, okay, that's a goal and so that's important for the install process. Later, because we installed this target set package. So, and then this is the labor. So maybe that's you can say it's also a version. So this is the version app store underscore one. This is my version, which I have seen. And then here's the path from the chain code. So it's not really complicated here. So okay, we can delete this and delete this file as well. Okay, so, and then the next step is to install the chain code on each organization. And these are the steps to put to prepare the organization one environment file. We did this already. And then we need the chain code install command. So, and with this command, P a life cycle chain code install and the name of their. So, and when you send this now to a second organization. So in our scenario, it's very simple because we have one physical one with machine. And then this virtual machine, we have two Docker containers and one for organization one and one for organization two, but in a real case scenario, maybe we have the networking different data centers because and we have connected this over the IP addresses or, or already, we will talk as one overlay network, for example. And so, but we have it on different machines, maybe so and different person should do this the organization is the administrator from organization one should do this and different person from the organization to or from another organization organization should do this. So, and we can send them this file and then he can inspect this jacket and then install it. And here you see the first time and output from the Docker chain code container. It's also good when you so try to modify your chain code. And you don't use testing. You don't think, okay, that's a minor changes. We don't need testing. And I don't have a test network or something like this. And when the process breaks from syntax error or something like this. And then you will see this here. So the syntax errors will be printed here to this to this time. But in my, in my case, we reached the done point here. And you can see, okay, successfully installed chain code. This, this is a good information. But we will have another information, which is now useful for us. So, look here, so successfully installed chain code with back a journey. So this is the abstract back a journey. And this is the hash of the chain code. And we need this. We need this on a later step. So, this is another environment where we were, we have to be. So we have to see, we have to take notice. So this is then here when we start. So when we improve. So we have to give the package ready. And we have to create an environment variable CC package ID with this string with the with the labor here. And that's the hash value here. And that's the reason why this is important. So when we install this. So, and so we can copy this. And you see, okay. So this is three nine and three, three nine and the first position. So, okay, that's the same hash. But this is not something related to the time. It's related only on the chain code. So when you have the same chain code, then you can install, you can install this chain code, and you will have always the same hash value here. So that's what hashes are for. So we have an input, and this input is the chain code. And when the chain code is not modified when the chain code is untouched, then the hash value will always be the same. And that's also important to know. So, so that's not a random hash. So these hash stands for exactly this chain code. Okay, so we have installed this so we can copy and paste this, or we can use another command to see which package ID is installed and we can copy this a little bit later also. So, but you have the possibility to copy this here, or you can use a command which I will show you a little bit later. So, okay, organization one is done. And now we have to switch to organization two. We do this in to execute the organization to environment variables. Yeah, I will show you the point and commands and with a grip of the core. So, as you will see, we have changed here. So organization to you have another port number. So also here the change organization to admin organization to remember with this command, you can see which variables you have set. Yeah, and then we can do the same again. We have installed this on the second organization. And you see the same process like before. The chain code will be created the chain code container. Yeah, we build it here. And if everything works, we will receive the same aside as for organization. So we've reached also done. And then we see also here the message. And you will see, okay, that's the same hash value as we have seen for organization one. So, I mean, you can also say, okay, when you send your, you can install your chain code on your, on your, on your beer, and, and then you can send the chain code to the organization to and give them your hash value. So they can compare the hash value if this is the unchanged chain code. So I think that's also an ability and security mechanism where you can demonstrate that this chain code is the same as we have, as we have sent him with this, with this easy track here. Okay, so, and that's it. Now we have installed this chain code on both organization. And if this command query installed. Can we check it. So we can check what is installed on this chain code on this on this channel. And you'll see here the same. And that's what I have meant. You can copy and paste this label and hash value from the output on this side, or when you don't have this output, you can create again with this query installed command, and then you have this again. Okay, so this is one. And now we have to, we have to do the proof process. So now we can say, okay, we switch back to organization one. So check it again. Okay, it's also installed this app store chain code. And then we have to set this for the improve process. We have to do this command here. Approve from my org beer lifecycle chain code approved from my org. And this needs some commands here some options here. Most options are always the same. So the, the option stands for the order. Here this is for the order or TLS, then channel ID is for channel ID. So the name is for the name of your app store. Oops. Be careful with this. And then we have a version. So this is version one. And then we are back at ready and then we have your secrets number. Then we have the TLS. I'm sorry to file from the TLS, TLS CA from the example. Dot com organization. And the important points here are these three options. And the back at ready is key. So the back at ready. This is the back at ready. So this one, the three nine, three nine. And when we have here for zero nine person and that's the same. So we don't have to control these numbers here. So, because if anything is changed in this chain code, then the hash will be completely different. So when you make a comma, then you will have a completely different hash value. So that's the aim of the, of every hash function. And then you will have here in front, not three and nine, or in the back for zero nine. So it's completely different. And you don't, you see it with, with, with mice. That's another change. That's another hash. So there is something wrong with this. So, okay, so then we export this environment variable. So, and then here I have always choose so parts, so parts, one command to explain and one command to copy. So this is the, the, the, the ready command where, which you can copy. And here is that we can discuss about this. So this is clear. So now we have environment variable with the dollar here. And then we have a sequence number and we have a version. So this is version one. And this is the sequence number. So the version one is something like, like the label, you can say, but you can give them a version number like you want. So in the session, the upgrade I have here. So what I've done in the upgrade, the upgrade process. So you see version 1.1. So that's what I have said. Okay, you can say we say we have a version number with three numbers 1.1, 1.1, 1 or 1.1, 0. And then we can say, okay, when we have a minor fix, a bug fix, or we have a new feature, or we have a change a code changing quick version, then we can here control this. But this depends only to you. So you can do whatever you want here on this position. And so that's the version. So and the sequence is a single number. So this is an increment number. So you have to increase this number on every chain code commit sequence, which you are going to do. So, and this is one sequence one, two, three, four, and so on. So, and I think that's the important parts here on this. So, okay. But we are not ready now. So I don't. So we have done we have the package ID. So we have to clear installed we have set the package ID. Ah, now we have to approve the chain code. So that's the step we are going to do. Now, we have to improve the check package. So, let me first check. Who am I. So I'm the organization one. Okay, so now as organization one. We, but the command is basically the same for both organizations. So, and with this command, we are going to approve the chain code for organization one. And you see, okay, committed with status valid that local host. So this looks good. And we can check now the readiness of this chain code. So, and this is the command check commit readiness of this chain code. And with this command, we can check how many of our of our organization has approved this chain code. And you see the commands here. It's basically the same. We have the channel we have the version and we have the sequence number. So, these both options must match this options here. The version number and sequence number. And this is for the TLS again, and the name of the chain code and the channel. And when we do this, you will receive this output approvals. And you see organization one is true. And organization true is false. And when we now try to install to commit the chain code, then the process will fail because we don't have the majority of the of the members. And so also organization two has to improve this chain code. Now we switch to organizational tool, and we can do the same. So the command is the same. There's no difference in the command. Check readiness. So we need the approved command. This one. And then we check the readiness again. And you see here, we have true and we have true. And now we are ready. So, we have installed your chain code on both organizations. We have approved the chain code on both organizations. And before we have approved, we have checked the chain code. And have tested it and have looked into it if everything is right. And then the final step is the committing of the chain code definition to the channel. And this command is basically the same from the options you see here. It's the same. But here, when we commit this, we have taken care that we have here all peers involved. So. And we commit the version one and the sequence one here. So. So, and now you can see, we have here. Two new transaction IDs. And that, that means that when we look at doc appears, we feel two running chain code containers. And that's what I have said before. So the chain code containers now are running. So, and we see here the app study labor. And here you see the hash of this. So, when you know the hash of your chain code, then you can be sure, okay, that's the right one. I have gave you to install it. So, this is a transparent process here. And both organizations here have a running chain code container. So, okay. And then one command left. So we can check up the, we can check if the query is committed. And yeah, for this, we need the channel one, the channel ID and the name. And the DCA file. So, there's also a command we can look into. And you see here, version one sequence one endorsement, blah, blah, blah, blah. And here approvals from one to two. These are the output where you can see. So, that means that when you come later to the system, then you can check which organizations has approved the strength code. And when we have two or three organizations more, and then we will see how they have voted to this. So basically it's a voting process. So you can vote for this chain code in the case that you approve it. And then we are ready to use this. So, and then our methods here. We have the init function, the invoke function query and delete because skip. So, the init function is, yeah, as we have seen in the last session. So there is no, there is, there is nothing new on this. So the only important new part is this highlighted field here. So you can see here with the C option here. I have a string, a JSON string, as I have explained in the last session. And then we have your function and we call it function directly from the chain code here. So, and I have done this here in the same way for the query. So we have function and we have a query and look here. So we have the invoke and we have the query here. So these are our target points here. And then we have the possibility to deliver arguments. And these arguments are always delivered in a string array. So we have for the query only the count one and the count two. And here for the init function, function init. So that's our basic first, first step that we say the account number one, we see 1000 units and account number two receive 10 units. So that we have an initial value to start. And you see, it's a little bit too fast. You can see that the printed, but we will see it a little bit later. And now we can query it. So we can query and you see here something like this. And the invoke is the same. So and the invoke function. We are going to say, okay, we will send 100 units from A to P. That's what our business contract is for. You see here. So you can scroll with the panel, but I have forgotten the finger keys for the scrolling here. So the only disadvantage, I think with the max terminal is that you cannot scroll like a normal terminal, but you can do it with a special combination. But I have forgotten. I'm sorry, I've forgotten this combination now. So I cannot scroll back here. But anyway. So, okay. And then we have another transaction. So, and you see, okay, we have here another number. So I'm sure this number 110. So, okay, and so on and so on. So the delete asset, we can skip. So, and then the system is running. So, and we use it a lot. And then the business guys came in and say, okay, we need now a modification. So we need in our system. And now they have decided that we want 2% of every transaction for us. And this is the new smart contract. And now this comes to you to the chain code developer to the chain code administrator. And now you're in a position to modify this. Now you have to do this process again. And then you have to change this existing system with, with the new functionality of the chain code. And this is basically the same work as we have seen before. And when we look here in this in the chain code, then the only thing I have done here is so this is only for simplicity. So I have, I have left this to integer values. So all in, because all values here in the trust. So I don't want to convert this all to a float 64 and float 46 data type. And I've introduced here the, the fee of 2%. And I have a new fee holder account created. It's called bank. And then we do a simple map of this. So we grab the old regret the money from the amount from this free from this fee holder. And then we calculate here the fee. So we have that's our amount of fee. We have calculated 2% here. And then we minus this 2% for the P. So because he has to pay the fee. And yeah, here the print commands. So in this print commands, you can see here in the, in the terminal in the, in the output from the terminal. And yeah, and then we do here the upgrade command and update the, the boot state with the boot state command here with the new free value. So, but it's not a really good example, how we can do this, but this year is only for demonstration and not for chain code best practice development. So I need something, I needed something that we can modify and makes a little bit sense that we can have a good example. So, but you can look into that and can try to improve this and try to improve this example to a float number. So that you can have really correct numbers for the, for the fee. So, and that's it. So, so, okay, the chain code developer said, okay, we are ready. Let's do this. And then the process starts again. So we go in the chain code container and chain code folder from the app store to to directly. And we do basically the same. So we have to install the dependence easier again. So nothing changed everything is the same. We need the conflict part for this. We have set the conflict path. And now we can package the chain code. And for the package to chain code. Okay, we say we gave them another name. That's the app store to talk. And the path is to the app store to it's also go lang the language and we gave them a new label. So the new label is then 1.1. So then we should have this package again. When we look into this, we see the same. So we have these two files inside. And that's basically the same. And then the process is really like the same. So we are looking we are organization one and then reinstalled this package. And the organization one. And here again, you see the output from this process. Okay. So, okay, this is ready now. And we check now also good to look into this. So, when you saw when you see queries when we call the query installed command. So you see here, you have two of them. You have the app store one with the first hash, and you have the app store 1.1 with the second hash here. So these packages are installed. And we have to set the, the, the, the new chain code back at ready environment with you. So I have, you can name it. I don't know the chain code back at ready, but I think it's better when you say here, it's new. So we can have a little bit more control about this. So, let us check the hash value. This is a seven. So I think the chain numbers are correct. So this is this. And then we can improve this organization one as well. So we say we trust us. And then we check the awareness. And you see the Russian one with the sequence to. So that's important here. We don't, we must carefully to not to be not the fast here. So you see here's the sequence one because it's the second iteration for this chain code, and we have a version 1.1. So, yeah, and that's important to see the difference between the version number and the sequence number. And when we create this chain code for the readiness, then we have to use this again. Okay. And then we have to switch to organization to organization to has also been started. Okay, they checked it before, and they say, okay, that's everything is fine. And when they come to this point, they, they will install the new chain code. And when everything is fine. Yeah, then we can check also on the second organization the situation with this and we can see, okay, we have also here, these two packages installed. And we have the eight at seven. So, that's correct. And then we can also, and with the readiness command, we see the version one with the sequence to is approved by these two organizations here. And then the final step is to upgrade this chain code now. And from now, we should have the new chain called in a new chain code container. So we have the app star one point one with the eight hash on organization to the organization one, we have the same. So, now we are seeing the upgrade process. And we are ready to test the chain code. And when we it's when we try to invoke and send 500 units from account one to account B, then we have here success and we query the bank. We have a fee of 10% of 10 units and 400 and 600. So, you can create a bank. So, I think we are at the end. So, let's sum up this. So, what we have seen here is that we have a new process to install a chain code on in the fabric network. And the main thing of this is that we have more control on the installation and and on the government. So that's why they call it governance life cycle. So, when we say in our life cycle endorsement policy from the whole network that the majority are a particular number of organizations must agree to changes to chain codes. Then we can initialize a process where the single organization can vote for this in a way that they have to improve it. And when this number is improved, when the majority is reached or the number is reached what we have, which organization must approve, then the new chain code can be installed and only then can be installed. And so that's, that's I think it's a good step in more control what is installed on the chain code. So, the interesting part is here there's some side notes I gave you. So, what happened if we find organization to has my notes as application and queries to data for something. And they have different input. We need a different input validation. And we have to make a small or minor changes to the chain code. So, how this work. So, where we can do this improvement. So, and the other scenario would be so what is when when a small pack exists. So, and the risk is when we say, okay, we have 10 organizations, and maybe in bonds in one certain situation, we have a pack in the chain code. So maybe something works and we can fix it very easily. And the system administrators on holidays are not in the office and so on. So how we can handle this situation in the real world scenario. And I think this is the reason why they have put in this, this, this, this hints and this, this, this text as to the documentation. So, but this is one what we have to discover what we have to try out and to see how the system works, how the system behaves when this real life scenario will happen. So, but this is not so. I think is there can be an error there can be a bug in certain situations. So that's not unusual in software development that some errors occur only in tested systems. So tested systems, even less. But everything that could happen will happen in the software area. And how you can handle this. So that's an important question how we can act as an administrator or as an operator and we can how we can handle this situation. So, and that's also it. This is something we have to test we have to build this scenario like this. And then we have to see how we can do this for the for the real world in the real world scenario. Okay, so I think I'm at the end. I hope I have seen you. Cool example from the chain code. And yeah, so if you have any questions, feel free and posted here. If I can answer it now then I will do it. And if not, I will post it on the slack channel then later. So, and yeah, do you have any questions. Roland does chain code upgrade procedure apply also when upgrading chain code package dependencies. This is a good question. I haven't tried this. But when we say that the hash value is changed from the package. Then I think we have to upgrade. Yes. So, I cannot say that 100%. But I think when you when some dependencies change from maybe an external go package, then the, of course, because go is a binary file. So, what you will have is a completely new binary file. And then you have a different chain code. So it doesn't matter if you change something like it doesn't matter if you change this output here to something like this, then you have a completely different chain code. Because the goal code will be combined in the binary code. So this is not executed. So in goal, we have the source code here, and then we have a executed with binary file and did that will be completely different. I don't know. I think that the, that the system who executes the, the ready chain code cannot different between these differences and say, okay, for this I can, I don't have to do an upgrade procedure. So I think we have to upgrade also the chain code when some dependencies change because a completely new goal program is built. And that's the reason. But we have to try it. So, but I think that would be a logic. This is Daniel. This is Daniel. Thanks for the great presentation up. I would have a question of how much do you know this is different if he was like external chain code and external chain code containers. Yeah, that's also a new feature. I haven't tried it yet now, but we will discover it in the series. So in one series later or in two series to meet up so we can look in this external chain code, because this is also a new feature. So I don't want to say at this moment something to that. So I would like to discover it. And then this is a feature which we can investigate or discover in a single meet up. I think how you can how you can how you can manage this. Yes. Please show the query history. That's a really good question query history. What do you mean with query history. You mean, maybe you mean the states from the past, or you mean all transactions to an asset. Yes. So, okay. That's also a question which we cannot cover here in this. So, what I know is that in the low level, in the low level shim API, so in version 1.4, for example, you can't query the history, the transactions from the chain code type. That is something I have done with the SDK. So you can do it with the SDK. And I'm not sure if you can do this from there with the new contract API, but make this make this sense. So, because when we query the transactions, we don't have to do anything with the ordering system. So, we have only our own PR. So we query the, the, the ledger, the channel and the ledger directly from our PR and not from the order on system. So we are not changing the white set. So that's not the functionality which is implemented in the chain code. And I think maybe it's also, so I think from, from my understanding it must be the same in the three week two version. So, when you look at the notary ssdk, you will find the examples how you can query all transaction to an asset. The invoke commands here, when, when we see here the init and then the invoke command, the boot state here, these commands only goes to the world state. And the world state is implemented in, in this case in the, in the, in the level to be database as a chain code as a state database. So, you have, you only interact with the world state of an asset. So, and as I have said in the last session, where we have the system is simple. So here they put this is the key, and this is the value. So that's the only thing that the chain that the blockchain do. So we store a key within corresponding value, and the value is in fabric, a byte string. So, and he is single and integer, but he can also chase an object. And these intact, these API interacts with the world state. And this, the world state is only the last state of an, of an asset and the transactions are stored also on the ledger. And that's also a good question, because the question here would be very cool how we can see a valid transaction and then unvalid transaction. Because when we do an invalid transaction, for any reason, the transaction is also stored into the ledger. But this transaction don't change, change the world state. And when, and when it comes to, to know, okay, how many people want to try to manipulate manipulate our system, then it would be interesting to see how many invalid transactions we have in the system. And that would be an interesting question, research question, how we can make a list from all transactions from an asset, which are valid, and from the transactions which are invalid. And that's an important part. So also, when the transaction is not valid, it will be stored on the ledger. But it doesn't changes the world state. And, yeah, but that's another story, how you can do this. But I think to answer your question. Finally, please look at the no chest SDK, or another SDK. And there you will find, was in the previous samples, you will find in the FAPKA or in other examples, you will find some no chest code, where you can clearly the history. And that means all transactions to an asset. And then I think to have you have to extract from this transaction the status and then you can see if this is a valid or invalid transaction. So I mean, I'm not sure how we can simulate an invalid transaction. So it's also a little bit and a little bit different, difficult to simulate maybe such a situation. So, but anyway, so that's a good research question, how we can list to these types of transactions of an existing or even deleted asset. And yes, the session is recorded. And after this session, I will send this to the to David possible. He's our connecting people to the hyperlature organization, and he will publish this meetup to the official hyperlature channel. And that will be in the next days. And then you can watch this on the YouTube channel from hyperlature. Okay, so any questions left. I have to say thank you for your time. And you see it takes a little bit more than one hour and one and a half hour. But I think we have this event only weekly. So, yeah, so I hope you're enjoying the session. And I hope we will see, we will hear us next time. And in the agenda, in the presentation, there is an agenda. And, and then I will publish then the topic for the next, for the next session. So you will be informed enough that you see what we have planned for the next time. Okay, so then I wish you all a good time, a good time and take care and stay safe in this time. And I hope we will see or hear us again in two weeks. Bye bye.