Hyperledger Fabric Tutorial, Luniverstar

[Resource materials]

Explanation on Demo DApp

Demo DApp is a simple service that allows you to fund idol groups, receive tokens as reward, and purchase products with the tokens. Front-end is developed with Vue.js and axios, and Back-end is developed with spring boot using Hyperledger Fabric official SDK. Back-end is linked to each comprising component of Hyperledger network and provides API that processes transaction into REST format.

Download DApp

  1. Download the resource material above and unzip the file. (hyperledger-luniverstar-sample-master.zip)

  2. Go to hyperledger-luniverstar-sample-master/free-trial directory.
    $ cd hyperledger-luniverstar-sample-master/free-trial

  3. Check for api chaincode directory.
    $ ls

DApp Front-end

Executing web server: You need to start a web server to access idol-funding Application on the browser. In this example, we provide web service using npm run serve. The example will be provided in the following order.

  1. Go to hyperledger-luniverstar-sample-master/free-trial directory.
    $ cd hyperledger-luniverstar-sample-master/free-trial
  2. Node.js is required to use npm. You can download it on node.js. Download and install the LTS version. If you have installed it before, you can move on next step.
  3. Start web server to begin idol-funding Application.
    $ npm install
    $ npm run serve
  4. When web server is successfully launched, log is shown as below.
DONE  Compiled successfully in 10488ms            

  App running at:
  - Local:   http://localhost:8080/ 
  - Network:

  Note that the development build is not optimized.
      To create a production build, run npm run build.
  1. Access "http://localhost:8080" on browser. Idol Funding Demo is a web-application not connected to blockchain yet.

Deploying chaincode for idol-funding

Under chaincode directory, there are chaincode source and zip files for Go, Java and Node.js. Select a zip file for your desired language and deploy the file referring to the following link:
Deploying Chain Code

At this point, what you need to be cautious of is that for Free Trial, you are using a shared network, so if the name of the chaincode you are trying to deploy matches the chaincode already deployed by another user, error would occur. Thus, we recommend naming chaincode by using something unique such as ID or date. Version expects strings of characters, not numbers. Therefore, you can enter in any format such as v1.0, 1.0, 1, etc. For Init Parameter, copy and enter the following text:

Setting up Server

The server contains codes that directly connects to blockchain, so you need some settings. You can refer to "Preparing for DApp Development" in the Developing DApp on Hyperledger Fabric
to check the following instructions:

First, download a connection profile file about Fabric Network and move it to api directory.

  1. Go to api directory.
    $ cd hyperledger-luniverstar-sample-master/free-trial/api

  2. Move a downloaded yaml or json file to current directory.
    $ mv ~/Downloads/connection-profile-Hyperledger.yaml ./

Next, download MSP information file and unzip it. Then, keystore and signcert folder will be created under msp folder and each folder contains a private key and a certificate. Move these files to api directory too.

Executing Server

  1. Go to api directory.
    $ cd hyperledger-luniverstar-sample-master/free-trial/api
  2. Luniverstar run by maven, so you need to install maven first. You can install maven through Homebrew easily. If you have not installed Homebrew before, you can go to Homebrew and copy the installation command and paste it on terminal.
    Copy and paste the following command to install maven.
    $ brew install maven
    Check out if maven is installed successfully.
    $ mvn -v
    If maven version check is right, you are ready to run server.
  3. start server.
    $ mvn spring-boot:run -Dspring-boot.run.arguments=./connection-profile-Hyperledger_Free_Trial.yaml,channel name,chain code name,chain code version
    예시) $ mvn spring-boot:run -Dspring-boot.run.arguments=./connection-profile-Hyperledger_Free_Trial.yaml,mychannel,luniverstarTest,1.0
  4. Log is as follows after you start server.
2019-12-24 16:59:10.478  INFO 12450 --- [           main] c.l.hledger.demo.DemoApplication         : Starting DemoApplication on Sucheolui-MacBookPro.local with PID 12450 (/Users/christin/work/demo-idol-funding/api/target/classes started by christin in /Users/christin/work/demo-idol-funding/api)
2019-12-24 16:59:10.481  INFO 12450 --- [           main] c.l.hledger.demo.DemoApplication         : No active profile set, falling back to default profiles: default
2019-12-24 16:59:11.265  INFO 12450 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http)
2019-12-24 16:59:11.274  INFO 12450 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-12-24 16:59:11.274  INFO 12450 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.29]
2019-12-24 16:59:11.324  INFO 12450 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-12-24 16:59:11.324  INFO 12450 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 788 ms
2019-12-24 16:59:11.455  INFO 12450 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-12-24 16:59:11.613  INFO 12450 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8081 (http) with context path ''
2019-12-24 16:59:11.616  INFO 12450 --- [           main] c.l.hledger.demo.DemoApplication         : Started DemoApplication in 1.398 seconds (JVM running for 1.716)