The following prerequisites are required to run a Docker-based Fabric test network on your local machine (001-pre-requisites.sh).
# Update your Linux system
$ apt-get update
$ apt-get upgrade
# Install the latest version of git if it is not already installed.
$ sudo apt-get install git
# Install the latest version of cURL if it is not already installed.
$ sudo apt-get install curl
# Optional: Install the latest version of jq if it is not already installed (only required for the tutorials related to channel configuration transactions).
sudo apt-get install jq
# Install Node JS
$ sudo apt-get install nodejs
$ npm
Setting up Docker
# Install the latest version of Docker if it is not already installed.
$ sudo apt-get -y install docker-compose
# Make sure the Docker daemon is running.
$ sudo systemctl start docker
# Optional: If you want the Docker daemon to start when the system starts, use the following:
$ sudo systemctl enable docker
#Add your user to the Docker group.
$ sudo usermod -a -G docker <username>
$ sudo groupadd docker
$ sudo usermod -aG docker alexandrebarros $USER
$ newgrp docker
$ docker run hello-world
$ docker ps
$ docker ps -a
$ docker images
$ docker logs --tail 20 [processIdNumber]
$ docker restart
# Reboot if still got error
$ reboot
Install Fabric SDK for NodeJS
The Hyperledger Fabric SDK allows applications to interact with a Fabric blockchain network. It provides a simple API to submit transactions to a ledger or query the contents of a ledger with minimal code.
The client API is published to the npm registry in the fabric-network package.
npm install fabric-network
Install Docker Images, Fabric Tools and Fabric Samples
cd /fabric-samples/test-network/
./network.sh down
./network.sh up -s couchdb -ca -verbose
Change into the first-network directory and run the generate script that will create the certificates and keys for the entities that are going to exist on our blockchain.
This will also create the genesis block, the first block on the blockchain, among other things.
Use this to generate cryptographic and network artifacts, bring up the network & run a sample scenario
# before starting, we need to set a path to the binary tools:
export PATH=../bin:$PATH
cd fabric-samples/first-network
# to create the cryptographic and channel artefacts
sudo ./byfn.sh generate
# to bring up the network and run a scenario using chaincode
sudo ./byfn.sh up
# to stop the network and clean up the system
sudo ./byfn.sh down
Interact with the network
cd /fabric-samples/fabcar
~/fabric-samples/fabcar$ ./startFabric.sh javascript