/Hyperledger-Fabric-basic-network

:wrench: Basic network for a Hyperledger Fabric project development

Primary LanguageShell

Hyperledger-Fabric-basic-network

Basic network for a Hyperledger Fabric project development.

Table of contents

Pre-requisites

  1. Hyperledger Fabric v2.2
  2. Hyperledger Fabric CA v1.5
  3. Docker v20.10
  4. Docker-Compose v2.14.0
  5. NodeJS / TypeScript v16.13.0
  6. npm v9.2.0

Hyperledger Fabric network

The Hyperledger Fabric network consists of:

  • One orderer
    • orderer.example.com
  • One organization
    • MSPID: Org1MSP
    • Two peers:
      • peer0.org1.example.com
      • peer1.org1.example.com
    • One CouchDB state database deployment for each peer
    • Fabric CA
      • ca.org1.example.com
  • Fabric CLI

Network deployment

Deploy the network

  1. Install Hyperledger Fabric latest docker images and binaries.

    ./install-fabric.sh

    this will generate a fabric-samples folder inside the project directory.

    Note: The fabric-samples folder is not needed, as we will only be using the downloaded Docker images to deploy the network

  2. Generate the network artifacts.

    cd network-files
    ./generate.sh

    Network deployment

  3. Deploy the network.

    ./start.sh

    Network deployment

  4. Teardown the network

    ./teardown.sh

    Network deployment

Web Application

A Web Application is made available using Nest.js

cd webapp/

Installation

npm install

Running the app

npm start

Web Application

Using the Web Application

Transactions

Transactions can be submitted via the web application. The Nest.js webapp supports both invokes and queries to the blockchain.

The application listens on localhost:3000 and has two endpoints:

As mentioned before, this chaincode needs to be initialized in order to use it. Therefore, the Initialize function can be called via POSTMAN. Web Application

Furthermore, an Invoke can be made via POSTMAN to Mint some tokens Web Application

  • http://localhost:3000/query

    body:

    {
        "function": "FunctionName",
        "args": ["list", "of", "arguments"]
    }

    Similarly, a Query can be made via POSTMAN to get the account balance Web Application