hyperledger_fabric_sample

module
v0.0.0-...-f10283f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2019 License: Apache-2.0

README

About Project

This is sample Hyperledger Fabric blockahain Application. Which contains two organizations as

  1. Doctor
  2. Generalpublic(Patient)

This will be containing the project upto building a frontend using ReactJs and Nodejs.

Getting Start

Clone this repository by Issuing following command In terminal

git clone https://github.com/Tharinducs/Hyperledger_Fabric_Sample.git

Creating channel artifacts and crypto-materials

Then go inside Hyperledger_Fabric_Sample folder

cd Hyperledger_Fabric_Sample

Open this folder in your text editor I prefer #Visual Studio code.

Then open a terminal inside Hyperledger_Fabric_Sample/pmschainsolo.

Then create two folders inside pmschainsolo folder as following

  • channel-artifacts
  • crypto-config

Then Run generate.sh file using this command.

./generate.sh

Now You will have all the binaries inside channel-artifacts and cryto-config folders.

If you need to increse the ammount of organizations you have to edit the crypto-config.yaml, configtx.yaml file according to your requirements.If you increse the ammout of organizations you have to change generate.sh file accordingly.I will have some articles on Medium how we can do this and complete explanation about commands in generate.sh file.You can follow me on Medium to get in touch with those. Tharindu Sandaruwan

Creting the network

For that open this file pmschainsolo/docker-compose-cli.yaml.

Then edit folowing areas.

- FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/ce9da2b3c37d18b04361afdfb2f65dd892157cdabacd4fb86dc7dd0cd488fa98_sk command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.generalpublic.pms.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/ce9da2b3c37d18b04361afdfb2f65dd892157cdabacd4fb86dc7dd0cd488fa98_sk -b admin:adminpw -d'

This file name ends with _sk should rename accroding to the genearted ca-cerver-congigurations keys generated in previous step for both organizations.

The ca-sever-config file path for both organization is here.

pmschainsolo/crypto-config/peerOrganizations/doctor.pms.com/ca/......_sk pmschainsolo/crypto-config/peerOrganizations/generalpublic.pms.com/ca/......_sk

If you have increse the number of peers then you have to change following files accordingly.

  • pmschainsolo/base/docker-compose-base.yaml
  • pmschainsolo/docker-compose-cli.yaml
  • pmschainsolo/docker-compose-couch.yaml

Now you setup all your configuration for your blockhain network.

Running your Network

Now run startNetwork.sh file by issuing this command on terminal.

./startNetwork.sh

If you have anything running on docker other than Hyperledger Fabric please be carefull when running this command.If somthing running remove volumes and containers only related to hyperledger fabric and remove following lines from Hyperledger Fabric

`#removing all the containers echo "" echo "##### Removing all the containers #####" echo "" echo "" docker rm -f $(docker ps -aq) echo "" echo ""

#prune the volumes echo "#### Prune the network #####" echo "" echo "" docker volume prune echo "" echo ""

#down the previously build networks echo "##### Removing networks #####" echo "" echo "" docker network prune echo "" echo ""

#down the previously build networks echo "##### Clearing the System #####" echo "" echo "" docker system prune echo "" echo ""`

After suucessfully running that file Issue commands in clicommandreference file one by one.

Now you Have run a sample network using Hyperledgr Fabric.

Now we can install chaincode. For that I will install chaincode on one of peer in each organization to do that issue commnds in the clicommandreference file inside pmschainsolo folder which comes under title of installing chaincode.

After Installing the chaincode you have to instantiate the chaincode.

To do that issue the commands in clicommandreference files which comes under title of instantiate chaincode it only should done one one peer per channel.

Now we can do transactions.

Commands are in the clicommandreference file.

Now remove all the docker containers and volumes.

Then write your own chaincode and put it into the chaincode folder.

Then start the network again.

Then install your new chaincode and instantiate it on the channel.

Do transactions through cli.

Directories

Path Synopsis
chaincode
fabcar/go command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL