The anti-counterfeiting program allows manufacturers to create digital signatures of watches. These watches can then be transferred to other users such as retailers or private individuals. All events are stored as transactions in the blockchain. The traceability of the watches ensures that they are originals.
Retailers can be verified by manufacturers to perform verified maintenance on the watches. A retailer not verified by the manufacturer cnot perform transactions on the manufacturers' watches. However, retailers and private individuals are free to enter non-verified maintenance on the watches.
The application offers the possibility to track the life cycle of your own watches. However, it is also possible to view the transaction history of third-party watches if the manufacturer name and the corresponding serial number are known. This enables the possibility to check watches for authenticity before a purchase. The transaction type "ShowSalesInterest" ensures that the person who wants to sell the watch is also in possession of the digital signature.
- IBM Blockchain Platform gives you total control of your blockchain network with a user interface that can simplify and accelerate your journey to deploy and manage blockchain components on the IBM Cloud Kubernetes Service.
- IBM Blockchain Platform Extension for VS Code is designed to assist users in developing, testing, and deploying smart contracts -- including connecting to Hyperledger Fabric environments.
- Hyperledger Fabric v1.4 is a platform for distributed ledger solutions, underpinned by a modular architecture that delivers high degrees of confidentiality, resiliency, flexibility, and scalability.
- Node.js is an open source, cross-platform JavaScript run-time environment that executes server-side JavaScript code.
- Express.js is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.
- Bootstrap Bootstrap is an open source toolkit for developing with HTML, CSS, and JS.
Follow these steps to set up and run this code pattern.
You will need the following requirements:
- IBM Blockchain Platform Extension for VS Code v1.0.16
- VSCode version 1.38.0 or greater
- Node v8.x or v10.x and npm v6.x or greater
- Docker version v17.06.2-ce or greater
- Docker Compose v1.14.0 or greater
- Clone the repo
- Package the smart contract
- Setup network locally and deploy the smart contract
- Run the application
Clone this repository in a folder your choice:
git clone https://github.com/Reffx/watch-blockchain.git
cd watch-blockchain
We will use the IBM Blockchain Platform Extension for VSCode to package the customerloyalty smart contract.
- Open Visual Studio code and open the
contract
folder from this repository that was cloned earlier.
Press the F1
key to see the different VS code options. Choose IBM Blockchain Platform: Package Open Project
.
Click the IBM Blockchain Platform
extension button on the left. This will show the packaged contracts on top and the blockchain connections on the bottom.
You should see FABRIC ENVIRONMENTS
on the left side of the editor. Under this section, you should see Local Fabric
. Click it to start the Local Fabric.
The extension will now provision the Docker containers that will act as nodes in your network. Once the provisioning is finished and the network is up and running, you will see the options to install and instantiate the smart contract, the Channels
information, the Nodes
and the organization msps under Organizations
. You are now ready to install the smart contract.
- In the
FABRIC ENVIRONMENTS
section near the bottom, click onSmart Contracts
>Installed
>+ Install
. You will see a pop-up similar to the graphic below.
- Then select the packaged contract:
[email protected] Packaged
Note The 2.5.1 comes from yourpackage.json
line:"version": "2.5.1"
After the install is complete, you should get a message Successfully installed on peer peer0.org1.example.com
. You should also see that the contract is listed under Installed
under FABRIC ENVIRONMENTS
.
-
Under Smart Contracts you will see a section that says Instantiated. Click on
+ Instantiate
under it. -
The extension will then ask you which contract and version to instantiate — choose
[email protected] Installed
.
- The extension will then ask you which function to call on instantiate — type in
instantiate
- Next, it will ask you for the arguments to the function. There are none, so just hit enter.
- Next, the extension will then ask you do you want to use a provide a private data collection configuration file? - Click on
No
.
- Lastly, the extension will then ask you do you want to choose a smart contract endorsement policy. Choose
Default (single endorser, any org)
.
Once instantiation of the contract completes, you should get the message Successfully instantiated smart contract
and you should see [email protected]
under Instantiated
under FABRIC ENVIRONMENTS
.
-
-
First, navigate to the
web-app
directory, and install the node dependencies.cd web-app/ npm install
-
Run the
enrollAdmin.js
scriptnode enrollAdmin.js
-
You should see the following in the terminal:
msg: Successfully enrolled admin user app-admin and imported it into the wallet
-
-
-
From the
web-app
directory, start the server.npm start
-
You can find the app running at http://localhost:8000/
This code pattern is licensed under the Apache Software License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.