Last Updated: 2019-09-25

Requirement

QUTrack is a simple flask app, so it could be deployed several steps, which only needs python3.6, pip3, and related python packages.

Local deployment

git clone "github clone url"

cd BlockChainApp/app

Installation:

1.Create a python virtual environment.

Virtualenv keeps your Python packages in a virtual environment localized to your project, instead of forcing you to install your packages system-wide.

$ virtualenv -p /usr/bin/python3.6 venv

$ source venv/bin/activate

2. Now we need ethereum test chain like ganache.

Ganache is a personal blockchain for Ethereum development you can use to deploy contracts, develop your applications, and run tests.

$ npm install -g ganache-cli

3. Install python web3.

Web3.py is a python library for interacting with ethereum. Its API is derived from the Web3.js Javascript API and should be familiar to anyone who has used web3.js.

$ pip3 install web3

4. Flask:

Flask is a microframework for Python

$ pip3 install flask

5. Flask Restful

Flask-RESTful is an extension for Flask that adds support for quickly building REST APIs.

$ pip3 install flask-restful

6. Flask Marshmallow

Flask marshmallow is an object serialization/deserialization library

$ pip3 install flask-marshmallow

Start Ethereum Test blockchain server.

To deploy smart contract we should start test ethereum server. We are using ganache for testing. Type below command in terminal.

$ ganache-cli

Note: Execute the ganache-cli command in different terminal. Open new terminal goto the BlockChainApp/app then execute this command to run in background.

Ganache Account Address

Ganache gives us 10 default test accounts with 100 fake ethers in each account for transaction. We will use these accounts for deploying and setting values in contracts.

Ganache port

We can see the gas prize and limit along with host:port on which ganache is deployed. We will need this while deploying contract

7. SOLC Solidity compiler

$ pip3 install py-solc

$ python3 -m solc.install v0.4.21

Note: use only 4.21 version this app does not support the other version. If error occurs after successful installation then check SOLC is in the environment path. If it SOLC path error then try adding it to PATH variable in environment to fix error(this might work or might fail) please make sure you are checking what type of error or failure before using this. Also make sure to safely copy the path of SOLC to environment PATH if you do not take care of it all the PATH in environment might fail.

8. Type $ python3 user_block.py in terminal before $ python3 main.py command

9. Type this to run $ python3 main.py

(modify main.py port to deploy the application on different port, everything is the same as flask doc, add sudo for port < 1024 in the last step)

Links to refer:

Qusandbox deployment

Directly use the project already created in test2 server

If there is a need to update the code:

Start an old project, or the AMI with ami-0226200a0fcd87d12, then ssh the instance

Git clone or pull

Create new AMI

using existing postscript with new AMI in jdf to create a new project

How to use it?

The app takes three different data inputs:

  1. JSON Data
  2. Amazon Ion Data
  3. YAML Data

User must use either one of the data type to interact with the application.

Steps:

  1. Copy one of the example data that has been provided on the right side of the web page.
  2. Paste the data into the input area. Now click on the datatype that you have chosen and pasted into the input window.

  1. Make sure to select one example at a time and proper datatype format to avoid errors.

  1. Click on the type of system that you need to use.
  2. Click Submit the result will be shown in the table.

Basic

Using web3 to connect the personal ethereum network - Ganache.

Using solidity to generate the schema of a data structure called contract in ganache.

Post the json style data to backend, which suits the schema defined before.

Store data in to the block chain using web3, using the address of the contract.

In fact, value are stored in contract, while ordinary block only store transactions.

Using the functions defined in the schema, retrieve the data inside contracts and response to the front end.