Deployment Guide for Blockchain Node

NIMBLE T&T Blockchain Node Deployment

Minifabric:

Minifabric is a very handy tool developed by IBM Blockchain team.

Minifabric is an OpenSource which now can be located in Hyperldgerlabs github organization.

Minifabric can stand up a Fabric network on a small machine like a VirtualBox VM but can also deploy Fabric networks across multiple production grade servers.

Minifabric has been tested on Linux, OS X, Windows 10 and supports Fabric releases 1.4.4 or newer

Feature Highlight

Minifabric allows you to experience the full capabilities of Hyperledger Fabric.

  1. Fabric network setup and expansion such as adding new organizations
  2. channel query, create, join, channel update
  3. chaincode install, approve, instantiation, invoke, query and private data collection
  4. ledger height and block query and Hyperledger Explorer support
  5. node monitoring, health check and discovery
  6. never pollute your environment

Best tool for T&T Blockchain solution

Administating a fabric network is a very time consuming task. It need’s lot of configurtions to be addressed.

Definning different certificate authorities different certificate requests for each and every component (Peers, Orderers).

Minifabric is a vey handy tool which helps you to overcome the above mentioned issues and set up a fabric network within 5 minutes on you’re own.

It already supports deployment of chaincodes written in different languages which is a very plus point for EFPF platform because in the future there can be chaincodes implemented in Java , Node.JS , Python etc.

Maintainance of the netwokr is very easy. Since the minifabric cli supports different kind of operations we require in a production environment.

Such as :-

  1. Channel operations such as create, update, join peers to channels, channel update and channel query

  2. Chaincode operations such as install, approve, commit, upgrade, initialize, instantiate, invoke and query

  3. Query blocks and transactions

  4. Generate connection profiles and wallet files for fabric go/node/python SDKs and VS Code extensions

  5. Integrated with Hyperledger Explorer and Caliper 10.Run Fabric applications which work with Fabric network

The normal process of working with Hyperledger Fabric

Below list is to show you the normal process of working with Fabric.

  1. Stand up a Fabric network
  2. Create a channel
  3. Join peers to a channel
  4. Install chaincode onto peers
  5. Approve chaincode (only for 2.0)
  6. Commit or instantiate chaincode
  7. Invoke chaincode (using either minifab or your applications)
  8. Query blocks

all these functionality are provided by the minifabric tool.

Step by Step guide to setup Nimble T&T Fabric Node.

Prerequisites

This tool requires docker CE 18.03 or newer, Minifabric supports Linux, OS X and Windows 10

Get the script and make it available system wide

Run the following command for Linux or OS X
mkdir -p ~/nimble && cd ~/nimble && curl -o minifab -sL https://tinyurl.com/yxa2q6yr && chmod +x minifab

Define the spec.yaml config in the root of nimble folder.

fabric:
  cas:
  - "ca1.nimble.efpf.com"
  - "ca1.efpf.efpf.com"
  peers: 
  - "peer1.nimble.efpf.com"
  - "peer1.efpf.efpf.com"
  - "peer2.nimble.efpf.com"
  - "peer2.efpf.efpf.com"
  orderers:
  - "orderer1.efpf.com"
  - "orderer2.efpf.com"
  - "orderer3.efpf.com"
  settings:
    ca:
      FABRIC_LOGGING_SPEC: DEBUG
    peer:
      FABRIC_LOGGING_SPEC: DEBUG
    orderer:
      FABRIC_LOGGING_SPEC: DEBUG
  endpoint_address: "172.16.18.177" (Public IP)
  

Stand up a Fabric network:

./minifab up -o nimble.efpf.com -e true -s couchdb

-e -> expose endpoints true -c -> database type couch db.

During the stanf up process, it simply runs the minifab up command in your working directory. When the command finishes, you should have a Fabric network running normally using the latest Fabric release (currently 2.2.0) on your machine.

You will also have an application channel named mychannel created, all peers defined in the network spec file joined into that channel, and a chaincode named simple installed and instantiated.

This command is the command to use if you simply want to stand up a Fabric network with channel and chaincode all ready for business. Since it executes the majority of a Fabric network operations, the process will take around 4 minutes to complete if you have a reasonably good internet connection because the process will also download the Hyperledger Fabric official images from Docker Hub.

Installing the chaincode

For this porcess first you have to build the logistic smart contract project.

npm run build

Inside the root folder of the network perform below operations

cd vars/chaincode/

Create the directory to place smart contracts.

sudo mkdir logistic-contract && cd logistic-contract

Smart contracts are written from node.js in that case make sure to create node directory.

sudo mkdir node && cd node

Copy the logistic contract project in to the node folder. Based on the locatiun change the command

sudo cp -r  ../../../../../logistic-contract/* .

Now in the root directory of the network you can execute below commands to install the chaincode.

./minifab install -n logistic-contract -v 1.1 -l node -e false -p '"InitLedger", ""'

-v -> Version of the contract -l -> Lanugage of the contract -p -> Init command for the contracts

Approve commit and intialize contract and ledger.

./minifab approve
./minifab commit
./minifab initialize -p '"initLedger"'

Testing

You can test network and the contract with the minifabric it self. Execyte below command.

./minifab invoke -p '"getOrder","some id"'

GetOrder :- Is a method in the smart contract and InitLedger method initiates ledger with a dummy value with id some id invoke method will retrieve the dummy data if things are all fine.

Generating Connection profile

For the fabric client you need a connection profile which needs for the api gateway initiate the connection with the smart contract.

You can generate the connection profile with below command.

./minifab apprun -l node
Next