Dumbonet: Server side of the application

Last time we gave you little wind in your sails for writing smart contact. Did you succeed writing one for the Quotation asset? 😎 We need one more thing before start using it.

Here you can see that we have two sub-folders in our backend folder: one is transactions and the second one is server.

Let’s start from transactions. We will show you how to enroll admin, register user and invoke chaincode (for creating Inquiry/Quotation). Each organization has its own admin user as we said already. Enrolling admin will create a folder called Wallet where we store admins and users identities.

We will enroll admin in a few steps:

1. Create a new CA client for interacting with the CA.

2. Create a new file system based wallet for managing identities.

3. Check to see if we’ve already enrolled the admin user.

4. Enroll the admin user, and import the new identity into the wallet.

After enrolling admin, we will create a user in similar steps:

1. Create a new file system based wallet for managing identities.

2. Check to see if we’ve already enrolled the user.

3. Check to see if we’ve already enrolled the admin user.

4. Create a new gateway for connecting to our peer node.

5. Get the CA client object from the gateway for interacting with the CA.

6. Register the user, enroll the user, and import the new identity into the wallet.

The main function in the Dumbonet application is creating Inquiry. Without it, the application has no sense. So, we will show you how to write invoke transaction which we will call when we want to create our asset. We wrote comments in code, so you can better understand what’s happening in each line.

To communicate with this transaction from our front-end application we need a mediator — our server. We will use different endpoints for different needs. Here you can see all endpoints for Inquiry asset, and you can create similar for Quotation:

Because we already showed you transaction Invoke, now you will see endpoint app.post for creating Inquiry:

Inline 45 you can see how we can call invoke transaction and which parameters we need to forward.

Using this example you can create all other transactions and endpoints. For any insecurity and lack of confidence, you can always write comments here or contact us. This tutorial is a little peeking into our project but we will be happy to guide you more into details.

After setting Keycloak, connecting it with Angular, configuring your blockchain network, writing chaincode and server-side of application, you are ready for the final step. But more about this in the next article.

See you soon! 🤞

--

--