 Okay, so welcome to this Hyperledger Sweden meetup. My name is Roland and I'm happy to be your guest for today's session. And today we will have a session about Node.js. So the title is how to use Node.js for Hyperledger favorite application development. And then the session I will give you an overview of what we can do with Node.js. And especially regarding the Hyperledger certified developer exam. So this is resumed, this is closed for the moment, but it will be resumed in the middle of March. And that's the reason why I have chosen this topic that we can see what is needed to pass the exam maybe. So we can go a little bit through this curriculum and I will show you also how you can get started with Node.js on the client side and also on the chain code side. And yeah, so we can summarize this in with two pillars. So we can say we can use Node.js for application development for the chain code side. So there we have different possibilities. So the first one is Go and then Node.js and Java. I think these are the stable versions. And on the client side there is Node.js and I think also Go, but that's not stable for the moment. There was a new version one week or two weeks ago. And the certification, the certified Hyperledger developer certification will be resumed, but only in the language Node.js. So this is available for the chain code in Node.js and for the client side on Node.js. And that's the reason why I have chosen this topic today, that we can have a starting point to see how this will work and what we have to learn to pass the exam if someone wants to take this exam in Nautra, in April or to another time. And yeah, so small overview, then I will give you a guideline what is needed and then I have prepared these domains and competences. And so that can have an overview of what is important. And in the next and upcoming sessions, I will talk a little bit more about this chain code and client development. So and then I will pick some special parts. Today I will give an overview and I will use the asset-basic transfer example for that. So because that's a good starting point. And for the chain code and also for the client side, but then the client side, the example is for me or the official example is for me a little bit difficult to understand. So I have splitted this example in a more easier way to understand for me. And then we can see how we can use this Node.js example also on the client side. And yeah, so the references you can find here in the slides as well. And also all my examples here you can find in the GitHub repository. Yeah, short overview. So Node.js can be used for both for the chain code or smart contract development and also for the client side development. So for me, it's a little bit difficult, I think, so I came from the go side for the chain code. And but I think when you are a beginner and you come from a rep development side, then this is a good choice to start. And in the Node.js, we have this fabric contract API. And this is a high level API. So you will see a little bit later that we can make a chain code, make some chain code operations with very less code. So I think it's really easy to use this. And yeah, it's a little bit surprising for me. Because it's so easy to use this fabric contract API. And you have also the possibility to use the old version, the skin version. And that's a little bit low level. So that means that you need more commands and but you have more flexibility to do something. And for this, you have to use a Node.js version 12. Yeah, then you have to deploy it on on your peers. The deployment process is the same like for a go chain code. But with some options that you have to name the type of chain code for go lang. This is the default. And that's the reason why we normally don't do this. So but when we use Node.js, then we have to use another option to flag this that the process know that we use Node.js for this. And then but the process and the version 2.2 favorite 2.2 is the same. So with the installation, with the proof process and also with the commit in the end. So and then we can use the Node.js, Node.js as a chain code. And on the other side, we can use it more naturally, I think for the client application development and the end here is to build in West API. So I think that's the normal way. But you can also use a command line where you can create the command line program like we are going to do today so that we can call the commands from the from the terminal. And but I think when you use it in a web environment, then we have to use a West API. And then we need an express.js server, for example, or something similar to create this API server. And then we have a client on this. So then we can use any front end application, Angular, future, suyect, whatever you want to have a nice front end for your browser interface. And yeah, so but that's front side, client front side web development. So that's a little bit out of the scope here. And we have here this thing to deploy an API to create an API that can that we can use. And that's normally the West API. And for this is this we have a so called application SDK software development kit. So and on the smart contract side, we have an API. So an application program programming interface. So from from the term to differences. And here we have also npm packages. So we have to use Node.js uses npm normally for his package management. And we need some external dependencies. We need here the fabric chain code node npm package. And on the client side, the fabric network, the fabric CA client, for example. And there are some some others as well. And here we can use the version 10 and 12. So from the Node.js version, when we when we have to deploy your component or create an environment or a development environment, then it's when we make this both the Node.js, the chain code, and also the client application, then I think we should use Node.js 12. Then in this way, we don't have to switch between 10 and 12 versions. But we can use this on the on the client side. But I think it's better when we use the same version. It's easier to work with. And with this with this software development kit, we can create application, a client application, which can interact with the with the blockchain system and can invoke and query some data. So and these are the global steps we have to do. And we look a little bit deeper what we have to do. Then we can say for the smart contracts, we need a development environment for local testing for this for the creation process of the chain code. And there we can. And for this, we can use the peer def mode. This is the environment which we have seen in the last meetup. So we can use also the native version or the binary version or the Docker version for this. And then we can deploy the chain code and we upgrade the chain code on the PS. So that's also one of the interesting steps. So in mostly we see the deployment of a chain code. So we have a chain code and then we deploy it and then use it. But what is the upgrade process? So and that's also an interesting part when we try to upgrade the chain code. So we can develop and then we can deploy the chain code on the peers and then also on the upgrade the chain code. And for the client development, it's a little bit different. So for the client application, so we need, I think it's better to have a small test network, something like the test network for neophobic samples because we need to prepare a connection profile. So the connection profile is responsible for the connection to the peer. And we need also some identities. So we need a user which is allowed to interact with the network. And we have to prepare. And that means that we have to enroll and register and enroll a user for this client development. And this process could also be done with the node shares. And in this field, we have two possibilities. So we can use an existing identity and then convert this existing identity in the local wallet from the client application. Or we can register and enroll a new user. But for this, we need a running certificate authority. But the test network will help us with that. So when we install deferred network, the test network from the user side, per default, two users in every organization will be created. So we have an admin user. This is the user which we normally use for our testing and for the installation of the chain code and for the administrator part. And then we have a user which is called user one. And this is a normal user. And we can convert this normal user as well to a wallet, to an identity, which we can use in the client application. And for when we choose this path, then we don't need the Phyrix CI for our testing. But when we want to create a new user or different users, then it's better to use the certificate authority option. And that's the good thing, I think, in the version 2.2 and then the test network from 2.2 because it's very easy to start a test network with certificate authorities because it's only a flag to do this. And then we have a running network with two certificate authorities, one for organization one and one for organization two. And this step is a little bit complicated in the version 1.4. So because the test network where you build your first network example hasn't this possibility to easy start then certificate authority. And that's the reason why I think this is a good improvement also for the testing and learning and development. And we can easily start and certificate authority and then we can register and enroll some identities. But we have to use the notary as SDK for that. And we have to write a script or something like that to that we can do this. And then when we have this in place, then we can write the application. So that means that we cannot start and say, okay, we write now and fabric application. So we need some preparation. And I think we should use for that the test network because we can have any configuration what we want. So also we can use a CouchDB for example. So when it comes to which queries, when we have a chain code where which queries is used or some aggregation functions or whatever CouchDB offers to use. Or we use the leveled B as a state database. And in this case, we only can use some key queries, key range queries or composite keys. And but it's also okay, but it depends on the use case. But we can all we handle all this. We can handle all this scenarios with the test network. And that's the reason why it's a good choice. And then we have to prepare this connection profile and this connect and with this preparation of the connection profile that the name I think it's 100% correct because the test network has prepared this connection profile. But we have to read this connection profile in our application. And that's the first step we have to do. So but we have to prepare it for our Node.js application. And then we have to enroll the users or the identities for this. Yeah. So in those are the steps we would like to do. We have to do. And when it comes to this certification, then here I have a copy of the domains and competences. And you can see the most part here, 65% are about the chain code development. And we can see here the competences we have to have to pass the exam. And we say here often the client application identity management, instantiation, a wallet, import identities to a wallet on selected manager entity from a wallet. It's it has only 7%. But I think it's an important step. But without this part, you will not have a possibility to connect to your favorite network. Also the creation of the network, the connection profile is an important part. So and yeah, but the main part here is about the chain code development. And yeah, and not so much about the client application development, I think. So we have only here in this two small parts. And the most part is about the chain code development. And here we have 20% from maintenance and testing. So there are some special topics here, unit testing, for example, for contracts. So that's an interesting part, but depends a little bit on the tools. So when you use go, for example, then you have a good testing environment because go has good testing features. In Node.js, you can also have good testing features. Yeah, so but it depends a little bit then on the language you use. And yeah, probably shooting transaction flow is also, I think, important part. Because as a developer, you have to understand how FAIRIC is working. And that's could be a little bit difficult to understand this, how all the single piece fits together. But normally from the whole perspective, from the global perspective, I think as a developer, you can use these tools and the client application and the Node.js application, the chain code, the Node.js and chain code. And in this way, you can create an application and you can install this application also on a managed system like an ABM or you can have on Google Cloud or on other public cloud providers. They offer managed FAIRIC networks and then you can use it and install it. And that's not so complicated as if you try to run your own network. But this depends on the use case and what is the aim of your project. But here you can see some important parts we will see today. And in the next sessions, I will pick some important other parts. For example, the event part. This is also interesting to see register and handle channel-based events. And for example, so that we can see what is a new block is created or we can send an email when the transaction is completed or whatever. So there are a lot of possibilities what we can do. So and yeah. And some points we will see today here. So, okay. There are some questions. Okay, so yeah. So that's so far the introduction here. And I haven't here the link for this official domains and competence sheet. But you can Google it and you will find it on the Linux Foundation page and also some other useful information. But I think it's important when you try to learn this, then you can see this is a small guideline to focus on different aspects here. But because when you see here in part the wallet topic, then when you look at a little bit deeper onto the wallet topic, then you will see that we have three different kinds of wallets. So we can have a file wallet and in memory wallet and also a database wallet. And with this we can create different combinations from applications. So and yeah. So we have here a lot of possibilities to do and to develop some things. Okay, so let's start with the practical part. So make this a little bit larger and here. So today I use two terminals for that. So in the first terminal, we would like to run the test network and we will install the train code. And in the second test, in the second terminal here, we will create, we will test our Node.js application. And when we try to start this, that's pretty straightforward. So there is no secret. So we use the test network again. And here's the command. So we have here this network script and this network app. We can create the channel. So and with the C option, we can name the channel. And here this is new in our session. So with this options CA, we can create certificate authorities and for the network. So and this network has two organizations and we have two certificate authorities. And we can do this and then you will see you have, we have three organizations. We have also the other organization and also for that and certificate authority is created. In a normal scenario, you will have also for the TLS and an own certificate authority. But here is only for the other organization, one organization, two. And that's the good thing on this Fabric 2.2 version. So because here we can create any configuration which we need. And now it's when it's on Docker PS. And then you see here we have here this is our normal setup. So we have the order and two PS, one for each organization. And here we have now two certificate authorities also running. But for example, we only need the organization CA for organization one. But all three are running. And you can create the also you can use it also when you make an client application for the organization too. For example, then you can register and use also from this. And you can also with this configuration, you can also learn a little bit about the Fabric CA. So that's also an interesting topic. So how we can register, enroll and delete or remove identities from this CA. And also when it comes to at root paste chain codes. So we can we can set some attributes to an identity. For example, this is the department marketing or sales or whatever. And then we can use this information into the chain code to have permissions on the chain code. So we can say this read process or this function can only use from a user from the sales department, for example, or whatever. So we can set different properties attributes to an identity. And then we can read it and can handle the situation in our chain code. So and now we have this in place and running. So and then yeah. So and then we have to use the chain code. So and then the favorite samples, we find different chain code examples for, I think the asset transfer basic. So has for all supported languages. And you see here a lot of examples. So all this which is with the prefix application. So that means for the client side. So you can have here the JavaScript version and the chain code here with the folder, folders with the chain code. They are for the, for the chain code. So we have here in JavaScript, you can type script one, one version if you go and one for Java as well. And yeah, we would like to look into this. And here we can see the chain code. So we can look in this chain code. So and then here you have this chain code structure. So the interesting part here is we need an index. Cheers file and we need here this lip folder and this lip folder. We have the chain code, the chain code, for example. So you see here, this is the init function. And here's a create function. Just a little bit. So, and that was the interesting part for me. So it's with the chain code, with this new contract API, it's really easy to create a chain code. Yeah, this is the favorite contract API implementation here. And with this is a high level. So when we say the create asset function here and that's it. So we can have here, you can make here an object. That's how you can, how you do it in node shares. And then here you have this put state. And the only thing what you have to do is that you create here to convert this asset here, this object here, to, to, to, to, to, to a Python, to a PyTerry. And that's it. So, and we have two lines of code to create an asset. And I think that's really easy. And also the read function here. When you read an asset, you can also say, okay, that's the read, the get state. So this is every, every time the same. So, and you have a get state. Then you have an asset in the JSON format. And then you can convert this, this is PyT. This is in PyT. And I think that's wrong here. It's not JSON. It's, it's, it's PyT. And with the two strings, you convert this buffer to JSON. And that's it. And, and with this, I think so. Okay. When you say this is the error, the error handling. So we have one, two lines of code. And with two lines of code, you can read an asset from your blockchain. And I think that's really easy to do. And also the update. So the update here is the same like the creation process. So you have, you see here, this is a bootstead and this is also a bootstead. So in fact, there's no difference between the creation and the update process because you create an asset. And the asset has an ID and has a buffer here. And, and that's it. And when you update, then you update also this ID, the asset with this ID, with a new information here. And then you have a new state of this asset. And that's it. And that's, and the new state is the new world state. And the new world state is then a way level in the state database in level B or in the, in the country B, for example. And that's it. So I think, and that's really easy to see how you can transfer asset here. So, but there's always the same. You have here a boot state and you override the last state of the asset. And that's it. So, and this is really easy to use. And also the get all asset method here is, so that's the history of an asset. No, it's not an history, get all assets is returns, returns all assets from the world state here. Yeah. So it's, I think you have here in, in the, in the get here, in the get example and read example, we will receive only one element here. Yeah. And here in this get all assets. So we, we, we receive multiple. So this is another function here, get state by range. And then here we can have a range. And when we don't use a range, when we leave it blank, then it means all assets. And here we receive an, we receive multiple assets. And then we have here a promise, here we can promise. And with that next, we can have a result here. And about this result, we can loop and convert every, every line in this, in this way to, yeah. So a record here, left record and past is to chasing. And then we can, in this example, it's all pushed to an array, to an object array here in this format. So we have a key with the key in the, in the, in the, in the from the blockchain. And then they record the information as a whole chasing object here. And yeah. And that's it. So, and you see also a function like a get all assets or it's clear here, a range of assets. It's really easy to implement here. And yeah. So, and that's, and that's it for this chain code example. And what we have to do now that we can install this. So when we look into this, so here we have to, when you copy this, when you clone this favorite examples, repository, then you have to install the NPN packages here. And here you see when we do the NPN install, then all these dependencies here, and we say here, these two dependencies, the favorite contract API and this favorite NPN packages. So these are dev dependencies, it's only for testing. So we don't need these for our chain code here. So that means we have to, in our example, we have to NPN install and NPN install. And then we can, then all these node models will be installed and loaded. So I have, I did this in the preparation here. And, and that's it. So these are, this is the same step as we did for the Go installation, where we use this vendor folder and the one vendor folder in the Go world is also managed, also the external dependencies. And here the node modules, this is the same for the, the world of node shares. Okay. So, and when we have NPN installed, then we can switch back to our test network. And we have to configure this environment variable, favorite config path. And this config path must link to the config folder and the test network has this config folder here. And the important part here is the core YAML file here. So that is the file which the config path path here needs. You can check this with the nth command. And just see here, grab, there we can just see here. This is your path. nth is the same like print nth, it's the same command. And then we have to back edge this chain code. It's the first step. So you can, you have this command be a life cycle chain code back edge. So we say this is the, and the back edge is entire, entire back edge, a tipped top back edge. And this is the outcome. This is the result. And here is with the path option. This is the path to our file from this current location here. And then so we can do this. This is the command. And this is the flag. So which I have mentioned earlier. So we have to say, this is no cheers. And we do that with this length option here. And this is what when we use go, this is the default language. We don't have to set, but when we use another language, when we use Java or JavaScript here, then no cheers here, then we have to use this flag. And the label is the same like every time here. Okay. So then we should have here a basic tar file here. And yeah, that we can. So to work with the test network, we need also to set some environment variables. And the test network gives us a script. It's called a nth var. And you find this under the scripts folder. And we can use this. And with this, when we use the script, then we have to possibility to use a function setGlobers. And with Globers one, we can switch or set all environment variables which are needed for organization one in this test network. And when we say setGlobers two, then we switch to the organization two and we use in both versions the PS0. So when we switch to using organization one, and then we can install this. We'll be a life cycle chain code installed. And then this tar package, we can install it. This takes some seconds. And you see here, so payload and we have identifier here. And the same for organization two. So we can, we can switch to organization two. And then we install the chain code also on the PR0, PR0 organization two. Okay. Then let us switch back to organization one. And then we have the possibility to check. So for the approved process here, approved from org, we need the package ID. So this package ID. And this package ID is this one here, this one. And we can create this also. So with this query installed command, and when we do this, and we see here, we can query the PR0 on organization one. And we see this chain code is installed here. So because we can install different chain codes on this PR on this channel. And yeah. So and we need this, is this identifier. So you see, this is the same identifier. Okay. We export this so we can use it a little bit easier. And then we have to approve this. Approve for organization one. This is all the same as we have seen in the, in the examples before. So yeah. So, but here important the package ID. So we need this particular package ID. And we have here the sequence one, because this is the first, the first right for this chain code. And version one, for example. So, but when we upgrade, for example, then we have to increase this number here. So yeah, but it could also be the version one, this chain code, because this is only for you. This is a naming convention for the human and not for the blockchain. And the sequence number is for the blockchain. So when we install an upgrade, then we have to hear also to increase this number. And this version could also be version one, because maybe we have an error in our chain code. And in our process, we are, we have version 1.1 or 1.0 and from this chain code. And we have to increase the sequence number on every chain from this chain code. That's the reason why this number can different to this number here. So, and then, yeah, we have a valid here. And then we can switch to organization two. So, and then we do the same. And this is not a different to the Go chain code or to the Java chain code. Yeah, this is always the same. And then we can use the commit command. And we have here two valid that looks good. And here we can see if this there's another command. It's called query committed. And then we see what is the result of the approved process here. And you'll see here the approvals. And you'll see, okay, organization one MSP, membership service provider has approved this. And the organization two membership provider has also here true. That means this organization has also approved this chain code. But there could be situation where if you have three organizations, for example, and you have the chain code life cycle endorsement or the chain code life cycle policy, the default policy and the default policy says the majority must approve a chain code. Then there could be a situation where two organizations has improved this chain code, but the third organization not. And you can own, but they can also install this chain code. In the network, but you can change this with your life cycle endorsement policies. And you can say, okay, only all three members has or have to improve this chain code. But in the default configuration, it's the majority and two or three are the majority. So that's the command where you can check how your organization has voted on this chain code, for example. Okay. And that's it. The chain code is installed. And the only difference between the standard way we should go is here. So when we package the chain code, we have to say language note. The rest here is always the same. And of course, you have to write the chain code in Node.js and JavaScript. And then you have NPM installed to do the NPM install that you can have the favorite contract API NPM packages or this Shim package. And that's all. But this process is the same like in Go when you use Go, then you also have to use to go vendor to load the dependencies. And here we also have to install the dependencies. So it's the same, but it's done a little bit different because of the different languages here. And but the difference here, this is new. So you have to set language node or language Java that you can use this correct. And the rest and the rest is the same as you install every other chain code. Okay, so then we have this one. And you see this, and you see here, you have here the chain code containers. And now you have some JavaScript or Node.js chain code containers run. And then you can start interact with this. And so, okay, so, okay, so here I have a test command. So we can test it with the CLA, with the command line. So we can, the first is that we have to init the lecture. So our lecture doesn't have any information now. And when we remember to this here, so now we have to call the init lecture function. And the init lecture function defines here some assets. And there is a simple loop, a for loop, over this assets area here. And with the put state function, the asset will be created in the blockchain. And this is the step we have to do first. This command is a little bit long because we have here to set the, you see here, so on the peers, we have here localhost, the first localhost here. So we have the localhost from peer zero organization one. And the TLS from this organization, from this peer here. And then you have the peer address from the second peer, here localhost 1951. And also the TLS code, the TLS root certificate here, the path to the root certificate. So that's important that because this is this majority rule. So when we have two, then we need the majority and only one has not the majority to invoke and chain code command here. So, and that's the reason why we have to use here in when we use the CLI command or this two peers. But when we use it with the node shares, then we don't have to do this. So we don't have to because node shares, the node shares SDK, will know how many peers the system needs to call this function. Okay, let us try this. And that's it. So, but we can close. So we use this blocks and follow. So, and so you can, you can see the logs here. And yeah, you see here, validated block six. Okay, so, and then you can create, for example, okay. Okay, so, and then we switch here to the second terminal. Okay, now I will only, so let me check this. And now you see there's an error conflict climate found, fabric conflict path. And that's the conflict path here. So that's the reason why we have to set this content path here. Oh, okay. We need, of course, we need this environment. And then we have to set some environment variables. So we say we are from the organization one. And then we can clear this. And you see here, we can use here, when you do this, then you have this as a string on the other side. And then we can pipe this. And you use the J code tool here. This is a JavaScript parser for the command line. Then you have a nice output here. And you see all the assets we have created. Yeah, so, and then you can create also one asset and so on. So, yeah. So that's what one, that's a tool. So, and now this works. So now we can say that we have used the Node.js as a chain code. We have installed this chain code. And now we have tested this chain code in the same way as we have edited in the past with the Go language, for example, with the Go chain code. And here you can also, for the an updated asset, yeah, we can try it. So, yeah. So, but this we will skip. And now we try this with the Node.js. And for this, I have created my app. And this is basically a copy and paste from the official, from the official example, but I have a little bit modified this so that we can understand it a little bit easier. So, so here, this application JavaScript folder. And this is the application here. So, and here you find all the information you need to do this, but it's a little bit difficult to understand how this works together. And yeah, so, but you can see here all the queries and all queries are related to this basic transfer example. And you can try it. And also the enrollment process, register and enroll for a user, enroll the admin and so on. Also the chain code and so on. But it's a little bit difficult to understand. And that's the reason why I have changed this a little bit. And I've created another example. This is my app here. And I have divided this, this example in three files. And I have here a helper file, which has here three functions which we need. So we need this build connection profile. So that is the function which reads the connection profile, which is created to the start process of the network script. And that's also invented from the network script. This creates this for you and JSON connection profile or a YAML connection profile in the JSON format or in the YAML format for organization one and for organization two. And with this script, we read the script from this file location here. And pass it as a JSON object and returns it to the usage here. So this and the connection profile contains all the information about our organization one. And we can print it out later and then see, we will see what is in this connection profile. And yeah, so and in this here, we have the build a build wallet function. So we need this build wallet function for the enrollment process of the administrator and the user and also for the ledger actions here. And then a small functions, the pretty JSON string so that you can stringify the return string to a JSON object here. So we have here three functions. And the first step is that we have to, we need some identities and to create the identities, we need an admin user. And when we start, when this FabricJ started, then the admin user has a default password. In this case is the user admin and this is admin password. So when you look into the Rocker Compose file, there is a separate Compose file for the certificate authorities and they are the username and password is set. And this is the default name for this. And here we need the wallet path. And then we have here some functions, the build certificate authority client, we need the client and then one function for the admin enrollment and one function for the user enrollment here. That user, so. And so let us try this. So and one important part, we need some dependencies. We need the FabricJ client dependency and we need the Fabric network dependency here. And so we can remove this and then we can say, okay, the first step is do an npm install and then these two Node.js models will be installed. And this, you can find this also here. So with the npm init, we create a node project and here the npm install. And then we have three files, this helper file, this CR actions and the lecture action here. This is these three files here. And the first step is that we need here a wallet. So this is the wallet path here. And then in this folder, the identities from your users are stored. So and we need the admin identity to register users and to enroll new users. And that's the reason why we first have to use this script. So with Node on CR, CA actions admin. I hope this works. Oh, this is not good. Okay, so I think we have a small problem here. So why is this not working? Okay, yeah, that's the same plan. That's a small error. So this is my helper script. And so this was because of a small trajectory. And here the same big wallet. So okay, now it works. So this is a problem from the refactoring. And so and now you see here a new file admin ID. And when we look a little bit into this file and you see here the information. So and we see here the certificate from this admin, from this user, the private key from this user, membership service provider and the type. And the type is always this format. This is X509. So Fabric CA and Fabric. This is the only type which is accepted here. And okay. So and in this CR actions file I have two functions. This get admin function. And then they get user function here. And yeah, this is a small command here. So I passed the name here admin, the models. You can see the models here. And then I call, I can read this with the process and arc variable here. And then we have here on the second position of this array, the arguments here, the second argument here. This is the second argument. And then if it's admin, then I call it the get admin function. And then if it's user, then I call this get user function here with the name on the position three. So and that's the reason why we say here, CA actions, user and beta. So we need the user beta, for example. Okay. So and this get admin function, you have it here. And this is here when you see this connection profile, we call this community connection profile. And then we need the CR client. And this CR client is also this is this build CR client function which we have seen earlier. And we need this npm package here, ferric CR client. And the connection profile and the name of the certificate. I'm sorry, this is organization one. And then here we have this build wallet function which I have split it in the build in the helper, in the helper file. And it needs also to parameters the wallet and the wallet path here. And then we can use this enrollment function here. And with this enrollment function, we have here the arm here, but here and you see here, this is the main function for to enroll an admin user. And yeah. And then here we see that here's the enrollment. And that's important to know. So the admin user is already registered. So this is registered when the ferric CR is started. And then we only have to enroll it here. And the normal user, we have first to register the user. It's here. So this is the, and then we can enroll it. So we have first to register a user in this certificate authority. And then we can enroll this user and convert this user to this wallet identity and put this identity in this wallet here. And that's the second part we have to do. So the first, the next step is that we use this function to call this function here. So this get user function, the say we want the user Roland. And now we have a second identity in our wallet. And you'll see here this Roland ID. And here when you look into that, then you'll see here the same. Now we have the certificate information here. And we have his private key to sign the request and the membership service provider. And yeah. And this is the first step in the preparation. So two first steps. So we need this connection profile or the preparation of this connection profile. And we need to use us the admin user and also an application user. And then we are ready to write our application. And this is Roland now. And to write the application, I did the same. I did the same. So I created here a script. And we have implemented here one, two, three functions. They get all asset function with an asset function and create another asset here. And this works in the same way. So because we need here the helper function with this to read the connection profile, then we need the information from the wallet. Also from the helper function. And then we need the gateway. So here we create the new instance of this of the gateway object. So here this comes from the fabric network. So here this is the wallet, which we have used also in the CA example. And we need the gateway from this. And here's the wallet path. So the wallet path is in the same folder. And this is the name of the folder. And these some constants here are the name of the user. And the user is the name of the identity. And then information about the channel, which channel we are going to query and which chain code we are going to query here. And then we have to make a connection. And that's pretty easy. So there's this connect function comes from the gateway here from the gateway. And we need the connection profile, the information about the wallet. Then which identity we should use. And then the information how the network, how the SDK should discover the network. And with the discovery true, then everything is done automatically. So then the notches SDK will use the gossip protocol. And we will discover all the informations in your network. And the only thing what we need in the connection profile is the path to one peer. So and then the SDK connects to this particular peer and then collects all the information about the network. And yeah, and as localhost that means only the flag is when we use this localhost. And this is the connection. So and I think that's also, I think to enroll and register users, that's a little bit complicated because you have to look what is needed and how you can query the CA and register and enroll in user. So that's the reason why I have split this in a separate file that we have this in another scope. And then when we have this information in place, then we need only less things to connect to the network. So we need this connection profile information. So this is stored here in this CCB connection profile. Then we need, okay, where is the wallet located? Because in this wallet is my identity. Then we need a gateway object. And this gateway object makes the connection. So and this is the same process as you do it when you use a database, for example, then you need also a username, a password, the host, a database name, for example. And that's similar to same information. So the connection profile is, where is your host information? The wallet is the place where is your identity stored and then what is the username, what is the identity? And of course, we have no password here because we use here the RSA component, the certificate and the private key from this user. So we don't need any password here. And the discovery here is only how the SDK can find the information about the network. And that's it. Then we have a connection here. And then the next step is, okay, when we are connected to the network, so to the channel, for example, channel to the PS0 from organization one, which channel we would like to connect. And if they get network from the channel, so we say channel one, that's our channel. Then we have a connection to the channel. And the next information is, which chain code we would like to use. And this is done with network get contract here and the chain code name. And then we have a contract. And at this point here, we are ready to use our chain code and query the information or create an asset or whatever we want to do in this chain code. And with this contract here, we can use two functions. So in this example, basically, you can use this two functions. So one is to evaluate transaction. So that's important because when you use evaluate transaction, then you send your query only to your peer, to a connected peer. And when you use the submit transaction, then you use the order. So that's the difference. So the submit transaction will always try to invoke the chain code, the create asset chain code, and it's sent to the orderer and the orderer does his work and so on. So, but this took, I think, so until two seconds in a normal setup, like we use it here. And yeah, that's a little bit too slow. But you can also use and read asset function with the submit transaction. It will also work, but it took some time. It took two seconds and it's not very efficient. So, and that's the reason why we have two different functions here in the contract class. The evaluate transaction is queries only your local instance and this is pretty fast. So, and when you submit something, when you create an asset, when you update an asset, when you transfer an asset, every time when you change an asset, then you have to use a submit function. And this is called submit transaction. And then the process works, so how many peers have to improve this transaction and then the SDK sends a broadcasting to all the peers and then the peers have to evaluate this transaction, have to simulate this transaction, sends the transaction proposal back and when all the transaction proposals are back and the SDK knows, okay, we have the majority, then we need at least two successful transaction proposals. Then the SDK sends the proposal to the orderer and the orderer does his work and then if everything is in place, the orderer committed this transaction to a block, orders the block and so on and then follows the typical transaction flow which is done in the fabric system. But you can also call this wheat asset with the submit transaction. So this will work, but it takes two seconds and because it runs through the whole process and it's of course better when we use this evaluate transaction function for queries. And that's also when we remember to the CLI example, then we have also the possibility to call invoke order query and the query means that it's queried the local peer and that's important to understand that here we have a specific query function which queries the local environment. So the local peer here, for example, peer zero from this organization and then we have a separate submit transaction which took some time until everything is in place. And yeah, that's it. So and when we try this here now, so then I have here, yeah, so and we can call this and you see and you see here the same website like before but from the client side. And also when we do the read asset function with asset one, okay, then there's an error because this is the error handling is not good implemented here. So and then this can clear asset two, three and so on. And you can also create an asset here and here we create a new asset, asset 14 with this informations and you see here then you see here the informations, the log from there and then we can see it works and yeah, so and this is how you can use Node.js for your client application. So I think with this simple steps here it's very easy to query to use Node.js as a client for your favorite network. So and there are only some steps to do and these steps are similar to maybe a database connection and the important parts only here. So when we can make here a console log, for example, for the CCD and you see here, this is the connection profile and you see here for the organization one, the connection profile has some informations about the BIAS. So what are the BIAS and what is the IP address and the address of the BIAS? What is the TLS certificate of the BIAS and so on. So and also for the certificate authority but this is only needed if you register and enroll new users. When you use maybe the user one identity which is automatically generated from the network script, from the from the build script, from the stats script, then you only need, you don't need this information because you don't need these certificate authority actions here and then you only need this in your connection profile and that's all what you need. So yeah, but this informations will be generated in your test network every time you, then if the system starts here and I think that's all the organizations, I don't know how is this script. Oh, we can look on the test network organizations, peer organizations on the organization one example. So here organizations, peer organization of course, organization one and then you have here these two files and you can use this as a JSON file or as a YAML file and when you look into this file then you see here all the informations and in this file will be created every time you, when you use the network script, this and the script to start and stop the network and if you want your own network, for example, then you have to create, then you have to create a connection profile in this way. So I think this work trace is easy to understand. So the only difficult part is how you can do this. So how you can copy the PEM content in this, in this single line file, but in I think the last or in one of my sessions there is a function in my repos where you can see how you can do this. So let's send one line up to do this. I think a set command. Yeah, and that's the connection profile. So there's no magic behind this. Then you need the information about your wallet. You need the wallet object and the wallet path. So this is this information in this folder all your identities are stored. Yeah, then you need the gateway. Okay, this is something an object. And then you have to connect it. And to connect it, you need this information, the connection profile. So what is your network? Whereas my wallet, which user wants to connect and is it local host or not? And should I use the discovery service or not? And then you have a connection. So the rate that's important that you use this rate here because that's an asynchronous function and the JavaScript has to wait until this function is ready. And yeah, and then you need, of course, the channel name and the chain code name. And that's it. And then you have the link to the contract. And then when you have the contract, you can do your basic functions. You can query all your chain code queries with the evaluate transaction function and the name. And also with the options here. So get all assets, doesn't need any options, but read asset has an option. Because we have defined this in the chain code. And then you can call and that's it. So I think that's easier in the database query sometimes. And also for the create asset. So when you submit the transaction, then you have to use this function here and send your parameters here. And that's it. And then you can disconnect from the gateway and that's it. So I think to query and to send the transaction is a little bit easier as to understand what is needed to get the user and to enroll and register and then enroll a user again. But this is something you need not so often. And yeah, but I think it's not so the important part to know is that when you want to create a new user, the first step is always to register this user. Also when you do it with the CLI. And then you receive a secret from this and then you can enroll it with this secret. So the user ID and the secret is important. So here this is an important step here that you store the secret and then enroll the user with the secret. And then here you put this into the wallet. So yeah. And with the wallet, this is the wallet here. And then you have here Roland ID and admin ID and whatever it is. Okay. So I think now we are done with basic overview how you can use Noteous as a chain code. And I think that's pretty easy to do. So especially for a simple or for a standard use case. And then you can use Noteous also for your for the client. And I think it's also not so complicated to do this. So I think it's more complicated to build diversity around this system. Yeah. And yeah. And the certificate of authority actions. This could be a little bit complicated and difficult to understand. Okay. Are there any questions? What provides the command set Glovers? This is this is the command set Glovers. So is it the function set Glovers? Yeah. And this function, the only thing this function does is to set different environment variables. With in fabric, when we use the CLI version, we have to define some environment variables. So this is the local membership service provider. So that we say, okay, we are someone from organization. We will use organization one. And the ID from organization one is organization one MSP. And this ID is configured in the conflict TXYAML file. So that's a simple name and ID from this organization. And then when we use TLS, then we have to define the path to the root certificate. And we have to say, okay, we are, what is the peer address? What is the, what are where is the membership service provider conflict folder or conflict user conflict folder? And just say it here. And this is from the admin user. So this user is working now in our example. So this is here organization one. We have for users folder. And this is the admin user. And then every user has a membership service provider folder. And in this folder are the important credentials for this user. And there's another user. As I have mentioned, user one or oneexample.com also with a membership service provider folder. This user identity, we could also use for our node shares example here. But then we, there's also a script where we can convert this existing to this wallet. And then here, the address, the peer address. And that's all. So, and the setGlobal function, in this test network, we have normally two peers, but there is an extended version where we can extend the network to a second or to a third organization. And that's the reason why we have here organization free MSP. And that's the job from the setGlobal function here. You can do this also without this function and export these free environment variables which you need. Any other question? Come on, one question. Nobody, don't be shy. Okay, if, can you evaluate on CDX and it's method stuff? I will explain very well. Can you evaluate on CDX, it's method instance? Yeah, that's in node shares. It's a little bit difficult because, so, personally, I tried to prepare myself for the developer certification. And I did my preparation with Go on the chain code side. And now I have to switch also to node shares for that. And I think we have to look at this information. That's not, not so easy to explain. So from the, I mean, this, you mean, so I think to understand this context and this stuff here, we have to look into the, not into the favorite contract API. We have to look into the favorite shim. And because this is in high level, so it's very easy to use this. And when we look into the, into the, into the favorite shim package, then we will see more about this context and about this stuff implementation here. We have only the, the, the, the extent from this contract. And through this contract, we have access to this, to this context and to this stuff here. And yeah, so to evaluate this a little bit more, we have to look into this favorite shim package. Okay, so is there anybody out there who wants to do the developer certification in the near future? So you have to do it also with no, in no chairs. Yeah. Okay, yeah. But now it's, it's stopped. So when you have enrolled it already, then I think the certification process is stopped now. And I received an email last week, this week I received an email last week. And then this email, there was a date, the 16th of March. There will be the start of the, of the certification. But I don't know if this time is the time where this is open to the public because they have the information, they gave the information that it will test it with the proc stars. So maybe this is only for the test, for testing for this exam. And not open for the public, but we will see. Okay. Yeah. If no questions, then I have to say thank you. I will publish the slides later and also the recording. And then you can, maybe you can try, try to reproduce this example with my script. And if you have any question to this script, then feel free to ask me. And yeah, so that's from my side. Thanks for your attention and your time. And stay safe in this time. And yeah, we will see you soon.