In this article the unique concept of MallCoin will be introduced. This currency can be built using Blockchain which can be used for redeeming rewards while shopping in the Clothing Shop. A Mallcoin application can be created and shown using Angular Web UI.
As a Blockchain developer you need to be very much focussed on tapping the untouched markets for creating applications. One such huge and major market is the Cloth shopping industry. There are numerous clothing brands which can use such application for increasing their customers. The clothing Shop member rewards program will help their business grow.
Clothing Shop Member Rewards
The Developer needs to understand that the customer should be doing seamless shopping. With this reward program the customer(or user in developer’s perspective) will be encouraged to shop more and more. This reward system can be constructed using the Blockchain Technology and AngularUI. A man cannot live without Food, Clothing and Shelter. So Clothing is an important aspect for any individual. If the user is incentivised then the user will come again and again to shop from that store.
The main task the developer to make a very robust and user friendly system for the admin and users. The system should work seamlessly across all the stores or branches of the clothing shop. So if the Clothing shop has various franchises then this system will work in all the branches. This will help
MallCoin
It’s really cheaper to retain customers than acquiring new customers. So a Clothing store cannot forget to gain this opportunity of retaining their customers. These are digital tokens awarded to the user for performing some activities. Such activities can be tracked using IoT. using Blockchain technology we can implement the digital tokens MallCoin.
The customers will be motivated to earn as many MallCoins. The Rewards can be designed by the Clothing Store owners to motivate them for more and more shopping. Such rewards system will be helpful to motivate the buyers to visit the store again and again. This will also urge them to provide special discount offers to the members while redeeming the Mallcoins.
Flow of the Project
Here we will do the implementation of the Clothing Shop Member Rewards system. We will use the IoT tracking and blockchain implementation by using MallCoins.
- Installation of Hyperledger Fabric and Hyperledger Composer
- Building and Deployment of MallCoin Blockchain Network
- Building and running of mallcoin Angular Web App
Before starting the project I urge you to checkout the Prerequisites.
If you are using Ubuntu, you can download the prerequisites using these following commands:
curl -O https://hyperledger.github.io/composer/latest/prereqs-ubuntu.sh
chmod u+x prereqs-ubuntu.sh
Next step is to run the script as this briefly uses sudo during its execution, you will be prompted for your password.
./prereqs-ubuntu.sh
- A) Installation of Hyperledger Fabric and Hyperledger Composer
Step 1: Installation of CLI Tools
The first step will be to install the useful CLI tools for the composer, which are essential. The composer(-cli) contains all the essential operations. We will also do the installation of the composer-rest-server.
a)Use of CLI Tools
npm install -g composer-cli@0.20
- b) Installation of rest server
npm install -g composer-rest-server@0.20
We have now done the installation of CLI tools and rest server. Let us go ahead by installing the Playground.
Step 2: Installation of Playground
This installation of Playground helps you to get User Interface for viewing and demonstrating your business networks.
npm install -g composer-playground@0.20
Step 3: Downloading of the Hyperledger Fabric Docker Containers
./downloadFabric.sh
Controlling the Blockchain Environment
Command for starting the servers:
./startFabric.sh
When starting the server for first time you need to load the Admin card in the network
./createPeerAdmin.sh
Run this command to stop the servers when required
./stopFabric.sh
Awesome! You have got a working Hyperledger Fabric and Composer Environment
- B) Building and Deployment of Mallcoin Blockchain Network
Step 1: Building the Network archive – bna file
So within the wolfpack-clothclub-mallcoin directory, run the command:
npm install
All the useful modules will be running behind the script for building the network archive.
Step 2: Deployment of blockchain bna (business network archive)
You should implement in the Hyperledger Fabric Engine
./wolfpack-clothstore-mallcoin/dist composer network install --archiveFile wolfpack-clothstore-mallcoin.bna --card PeerAdmin@hlfv1 composer network start --networkName wolfpack-clothstore-mallcoin --networkVersion 0.0.2 --card PeerAdmin@hlfv1 --networkAdmin admin --networkAdminEnrollSecret adminpw
Step 3: Creation of Composer card for connecting to the Network
composer card create -n wolfpack-clothstore-mallcoin -p ../../fabric-dev-servers/DevServer_connection.json -u admin -s adminpw
After entering the above command you will see a successful message:
Successfully created business network card file to Output file: admin@wolfpack-clothstore-mallcoin.cardCommand succeeded
Step 4 : Importing the Composer Card into the Composer Wallet
composer card import -f admin@wolfpack-clothstore-mallcoin.card
After implementing the command you will see a successful message.
Step 5: Testing the composer if its listening or not
In the command line, enter:
composer network ping -c admin@wolfpack-clothstore-mallcoin
You will see:
The connection to the network was successfully tested: wolfpack-clothstore-mallcoin Business network version: 0.0.2 Composer runtime version: 0.20.0 participant: org.hyperledger.composer.system.NetworkAdmin#admin identity: org.hyperledger.composer.system.Identity#6f8e156dde4d67f9c1c10cd4180b3fd5d9c7238b8039c306a7dc26a87eb74521 Command succeeded
Step 6: Starting Composer REST Server:
This Composer REST Server generates set of API’s based on the Composer Model.
composer-rest-server -p 3020 -c admin@wolfpack-clothstore-mallcoin -n never
Step 7: Loading of Sample Data
We will now load sample data. A Club named as WolfPack Elite, a few members and few stores and products.
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"$class":"org.clothstore.mallcoin.SetupDemo"}' 'http://localhost:3020/api/SetupDemo'
Step 8: Testing of the Data whether Loaded or not
curl -X GET --header 'Accept: application/json' 'http://localhost:3020/api/Member'
You will see the data returned in json format like this:
[{“$class”:”org.clothstore.mallcoin.Member”,”club”:”resource:org.clothstore.mallcoin.Club#CLUB_001″,”memberStatus”:”ACTIVE”,”personId”:”MEMBER_001″,”personFirstName”:”Chris”,”personLastName”:”Tyler”,”mallcoinWallet”:”resource:org.clothstore.mallcoin.mallcoinWallet#MEMBER_001″},{“$class”:”org.clothstore.mallcoin.Member”,”club”:”resource:org.clothstore.mallcoin.Club#CLUB_001″,”memberStatus”:”ACTIVE”,”personId”:”MEMBER_002″,”personFirstName”:”Darrel”,”personLastName”:”Pyle”,”mallcoinWallet”:”resource:org.clothstore.mallcoin.mallcoinWallet#MEMBER_002″},{“$class”:”org.clothstore.mallcoin.Member”,”club”:”resource:org.clothstore.mallcoin.Club#CLUB_001″,”memberStatus”:”ACTIVE”,”personId”:”MEMBER_003″,”personFirstName”:”Ashley”,”personLastName”:”Troggio”,”mallcoinWallet”:”resource:org.clothstore.mallcoin.mallcoinWallet#MEMBER_003″}]
Awesome! Now you have a working blockchain with data.
- C) Building and running of Mallcoin Angular Web App
The users will be able to interact the Blockchain using a UI written with Node.js and Angular 2 (6.x) framework.
Step 1: Installing the Web App
From the ./mallcoin-app directory you can enter the below command to install all the components locally
npm install
It will take few minutes to install.
Step 2: Running the web app
Make sure that you have started the Composer REST Server and you have run the SetupDemo transaction to load Data.
npm start
This will start the web app in this link http://localhost:3000 So open a web browser and visit the app.
Step 3: Accessing the Mallcoin Application
Finally now this is the screen where you see all your hardwork in the Web UI.
From this app you can do the following things with ease:
- Add new members to the Cloth Store (new members are loaded with 100 Mallcoins by default)
- Members can gain more Mallcoins
- Members can Redeem their hard earned Mallcoins with affiliated stores of the Brand.
- Members can see their Mallcoin History
- Store Admins can easily inactivate members.
Step 4: Add New Members
You can easily add new members, by clicking on the “Create a New Member” Button.
Step 5: Adding Mallcoins to Members
Now it’s upto you if you want to give mallcoins to members. This can be a rewarding task, by clicking on the third icon in the “Member Actions Column”. In this way you can easily add 25 Mallcoins to the members with one click. You can do so for rewarding the member to visit the cloth store. It can be for doing any buying activity, like shopping trousers. Also you can give Mallcoins if the member refers another member to the clothing store.
Step 6: Redeem Mallcoins
If you want to Redeem Mallcoins, it can be done with ease by clicking on the second symbol from the Member Actions Column. Here you will see this Redemption Form:
In this way you can redeem Mallcoins from the member’s wallet to the store’s wallet.
Step 7: Activity History
You can view the Activity History of the member by clicking on the Mallcoins Balance. You can refresh the page before doing so. When you click on the Mallcoins Balance of a member you will see a list of all the Mallcoin Transactions:
Step 8: Removing Inactive Members
As an admin you can now easily remove the Inactive members by clicking on the close symbol (Placed 4th in the Member Actions Column) next to the name of the member. Once you do it the member will be removed from the list of the members.
Wrapping Up
We hope you got acquainted with the process of creating Blockchain for Tracking Clothing Shop Member Rewards. Let us know in the comments below if this tutorial helped you. Till then stay tuned on our blog. Happy coding!
Also read : The Next Big Thing in Blockchain for Business
Nikhil Narkhede
Latest posts by Nikhil Narkhede (see all)
- SMTP Error 451 – How to Resolve? - March 11, 2024
- ASUS ROG Strix G16 Gaming Laptop - January 4, 2024
- Kids Camera – Kids Camera that Prints - January 3, 2024
Hey Nikhil, I am still learning Blockchain development. Now learning the installation of hyperledger. Thanks for the tutorial.
All the best Kshitij, let me know if you need any guidance or help. Will be happy to assist you. Welcome 🙂