GithubHelp home page GithubHelp logo

fabric_demo_cc's Introduction

Fabric_demo_CC

This project is a simple demo of Hyperledger Fabric with a simple Web interface for interaction, which is still under development.

This demo has the functions of enrolling users(who can perform the following actions), create channel, join peer(s) of his/her orgnization into the channel created, install chaincode, instantiate chaincode, invoke chaincode(move assets betweem two entitys), query chaincode(query entity's existing asset amount), query block and query transaction.

What it can perform is basically transfer asset between two entities. Some screen shots of the demo are as follows.

Login Page

Menu Page

This project is composed by several parts. The core underlying framework is Hyperledger Fabric, which is an implementation of blockchain technology. In order to make an interactive interface, Hyperledger Fabric Client SDK for Node.js is used. It provides the APIs to interact with a Hyperledger Fabric blockchain through NodeJS. Therefore, the backend of this project uses NodeJS, and React is used for frontend. The code to actually perform functions in blockchain is called chaincode, which can be written in GO/JAVA.

The process of making some calls from the user to the blockchain is as follows:

  • The user opens the web page of this project using browser and click something to perform an action.
  • The frontend send HTTP request to the backend.
  • The backend calls specific APIs of the blockchain(fabric) through fabric-sdk-node.
  • The underlying fabric handles the requests and may call specific functions of the chaincode provided to it.
  • The chaincode may modified some state of the blockchain.

Folder demoUI/my-app is the frontend code base. Folder asset-transfer/ is the backend code base, including script to pull fabric docker images and chaincodes. There is no fabric code base in this repository. It is leveraged through docker.

Environment Setup

I am using a Linux VM. (Recommand Linux System, otherwise you might met lots of problems) So the following setups are all based on Linux. Not sure if it will work or not on Windows or MacOS.

  • Docker - v1.12 or higher
  • Docker Compose - v1.8 or higher
  • Git client - needed for clone commands
  • Node.js v6.2.0 - 6.10.0 ( Node v7+ is not supported ) (should include npm, otherwise install npm seperately)
  • Go latest will be fine
  • cURL Usually it's already installed on Linux System. Check if it exists using curl --version in your terminal.

Place the project

  • Choose a place and create a folder at any place you like. Before cloning this repository into the folder, it's important to setup the GOPATH first. See HERE about how to setup the GOPATH. For example, you create a HyperLedger folder where you want to put the project, you need to set this folder path as the GOPATH first.
  • cd into this folder, and clone the project under it. Make sure all fabric related projects are under this GOPATH.

Setup the app

  • Download docker images (this might take a rather long time, and if you see errors, stop it and re-run the command again)

    cd asset-transfer/
    docker-compose -f artifacts/docker-compose.yaml pull
    
  • Once you have completed the above setup, you will be provisioned a local network with following configuration(defined in the artifacts/docker-compose.yaml file):

    • 2 CAs
    • A SOLO orderer
    • 4 peers (2 peers per Org)
  • Then run the application: ./runApp.sh If you see something like the followings, it means the backend has been successfully running on localhost:4000. Don't close it.

    [INFO] SampleWebApp - ****************** SERVER STARTED ************************
    [INFO] SampleWebApp - **************  http://localhost:4000  ******************
    

Start the frontend

  • Open another terminal. cd into the demoUI/my-app folder. Run

    npm install
    npm start
    
  • Open the browser, go to http:localhost:3000/login. You should see the web page.

Explanation

Detailed explanation about the files and some notes are provided in the README in each subfolder.

Touble Shooting

  • If you do npm install by yourself and see some errors. You can delete the node_modules folder first, and try npm install --unsafe-perm
  • If you see some errors regarding the tools (such as node, npm etc), you might want to check if you have properly set up the system environment for that tool first.
  • In case you are building the fabric docker image from their source code base, if you see errors Illegal file mode detected for file xxx, you can run chmod -R 666 {filepath} to change the mode of the file as some fabric source code have a check of that.

Author

Author : Misky Shi

fabric_demo_cc's People

Contributors

mizaoyu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.