Tanmoytkd / T-Drive

This project is part of a tutorial on Hyperledger Fabric showing how to use Hyperledger fabric to build a clone of google drive.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

T-Drive

This project is part of a tutorial on Hyperledger Fabric showing how to use Hyperledger fabric to build a clone of google drive.

T-Drive Architecture

Hyperledger Fabric basic commands

Coding Walkthrough (Video)

Prerequisites: (Git, Curl, Docker, Docker-compose)

Installing Git and Curl

sudo apt install -y git curl

Installing Node.JS

#install nvm (node version manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

source ~/.bashrc

#install lts version of node
nvm install --lts
nvm use --lts
nvm alias default --lts

Installing Docker

To install docker on your ubuntu machine, follow the steps from the tutorials given below:

Activate Docker Group (Executing the Docker Command Without Sudo)

By default, the docker command can only be run the root user or by a user in the docker group, which is automatically created during Docker's installation process. If you attempt to run the docker command without prefixing it with sudo or without being in the docker group, you'll get an output like this:

docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?. See 'docker run --help'.

If you want to avoid typing sudo whenever you run the docker command, add your username to the docker group:

sudo usermod -aG docker ${USER}

su - ${USER}

Confirm that your user is now added to the docker group by typing:

id -nG

If everything went well, you'll see docker in the output

Installing Docker Compose

To install docker compose on your ubuntu machine, follow the steps from the tutorials given below:

Installing Hyperledger Fabric:

cd $HOME
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s

Setting Up Environment Variables:

echo export PATH=\$PATH:\$HOME/fabric-samples/bin | tee -a ~/.bashrc

echo export FABRIC_CFG_PATH=$HOME/fabric-samples/config | tee -a ~/.bashrc

source ~/.bashrc

Downloading T-Drive

cd $HOME/fabric-samples

git clone https://github.com/Tanmoytkd/T-Drive t-drive

cd $HOME/fabric-samples/t-drive/chaincode-javascript
npm install

cd $HOME/fabric-samples/t-drive/api-javascript
npm install

Starting Blockchain Test Network and Install T-Drive Chaincode

cd $HOME/fabric-samples/test-network

# Start Test Network
./network.sh down && ./network.sh createChannel -ca -c mychannel -s couchdb

# Deleting the existing wallet from previous test network
rm -rf $HOME/fabric-samples/t-drive/api-javascript/wallet

# Install Chaincode
./network.sh deployCC -ccn tdrive -ccp $HOME/fabric-samples/t-drive/chaincode-javascript/ -ccl javascript

Starting T-Drive API

cd $HOME/fabric-samples/t-drive/api-javascript

npm install

node app.js

You can test the API with the REST CLIENT vs code extension. The tests are written in the file api_test.rest.

Viewing Blockchain State in CouchDB

You can view the current state at http://localhost:5984/_utils/.

Username: admin
Password: adminpw

Stopping Test Network

cd $HOME/fabric-samples/test-network

./network.sh down

About

This project is part of a tutorial on Hyperledger Fabric showing how to use Hyperledger fabric to build a clone of google drive.


Languages

Language:JavaScript 96.0%Language:CSS 4.0%