Whenever fire accidents take place, they cause great harm and destruction and sometimes loss of property. Thus, the factories usually take fire insurance policies to compensate for the loss. And if the factory claims for false insurance then also the insurance company compensates for the loss, so by buying the sensor data from these plants insurance companies can save themselves from false claims
In this example we have a Steel manufacturing plant called "HardSteel", which provides sensor data like temperature and pressure values to companies like insurance companies like "InsureLife" in this example through Industry Marketplace.
Required softwares for getting started with Industry Marketplace are as follows:
Node.js
We will use NVM for installing Node.js. NVM (Node Version Manager) is a bash script used to manage multiple active Node.js versions. With NVM you can install and uninstall any specific Node.js version you want to use or test.
First we will install NVM, to download and install the nvm
script run:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
The command above will clone the NVM repository from Github to the ~/.nvm
directory:
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
As the output above says, you should either close and reopen the terminal or run the commands to add the path to nvm
script to the current shell session. You can do whatever is easier for you.
Once the script is in your PATH
, verify that nvm
was properly installed by typing:
nvm --version
0.35.3
Now that the nvm
is installed we can install the latest available version of Node.js, by typing:
nvm install node
Once the installation is completed, verify it by printing the Node.js version:
node --version
v14.2.0
To list installed Node.js versions type:
nvm ls
The output should look something like this:
-> v14.2.0
system
default -> node (-> v14.2.0)
node -> stable (-> v14.2.0) (default)
stable -> 14.2 (-> v14.2.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.20.1 (-> N/A)
lts/erbium -> v12.16.3 (-> N/A)
The entry with an arrow on the right (-> v14.2.0) is the Node.js version used in the current shell session and the default version also v14.2.0. Default version is the version that will be active when opening new shells.
For deploying Industry Marketplace, we will be using v12.16.3. As there are some problems in using v14.2.0 with Industry Marketplace. Also note the for running the Service App Node.js v10 or higher is required. Therefore we will use v12.16.3
For installing v12.16.3 type
nvm install v12.16.3
After the installation is complete we will be making v12.16.3 as the default Node.js version. For changing the default Node.js version to 12.16.3, use the following command
nvm alias default 10.16.3
Yarn
Yarn is a new package manager that replaces the existing workflow for the npm client or other package managers while remaining compatible with the npm registry. It has the same feature set as existing workflows while operating faster, more securely, and more reliably.
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Since we have used nvm we will avoid the installation of node, by typing
sudo apt update && sudo apt install --no-install-recommends yarn
Note : Due to the use of nodejs
instead of node
name in some distros, yarn
might complain about node
not being installed. A workaround for this is to add an alias in your .bashrc
file, like so: alias node=nodejs
. This will point yarn
to whatever version of node
you decide to use.
Running the Industry Marketplace
Cloning the Industry Marketplace for provider
git clone --depth=1 https://github.com/iotaledger/industry-marketplace.git provider
Cloning the Industry Marketplace for requester
git clone --depth=1 https://github.com/iotaledger/industry-marketplace.git requester
Cloning the python-helper function for using the Industry Marketplace as a Sensor Data Marketplace:
git clone https://github.com/iota-community/industry-marketplace-python-helper.git python-helper
We will be running both the requester and provider nodes on the same machine, so we will change the ports of provider from 4000 to 4001. This is done using the different ports patch file in python-helper folder
So, firstly change the directory to provider/
$ cd provider/
Then apply the different port patch
$ git apply ../python-helper/patches/different_ports.patch
Also we will be using the comnet node as the devnet is no longer used by the IOTA community. So we will also apply a patch for changing the nodes from devnet to comnet.
$ git apply ../python-helper/patches/comnet.patch
Also apply this patch in the requester folder
$ cd ../requester
$ git apply ../python-helper/patches/comnet.patch
After doing all this we are ready to launch the ServiceApp
Launching the ServiceApp:
Currently we are in the requester folder, so we will first lauch the requester app:
$ cd ServiceApp
$ yarn run dev
After running this command for the first time, it will take some time in downloading the dependencies and deploying them
Open a new Terminal and navigate to the ServiceApp of the requester folder
$ cd requester/ServiceApp
$ yarn run dev
Once the development server is ready, terminal will look something like this
and on a new browser window Industry Marketplace will start and will look something like this
Our requester node is ready, now do the same ie launching the server for provider also
Once both the requester and provider are ready goto the python -helper folder
$ cd ../../python-helper
make a virtual environment for python
$ python3 -mvenv ../env
$ . ../env/bin/activate
$ pip install -r requirements.txt
and run
$ python service_provider
on a new terminal window, type the following commands
$ . ../env/bin/activate
$ python service_requester
Voila!!
Everything is setup and ready to test.
Comments
Please log in or sign up to comment.