A Blockchain application using Hyperledger Composer and BigchainDB for buying and printing 3D Printer models.
The idea is that designers upload their original models and set the price for each model. These models are avaliable to the end-users for 3D printing. The end-users select which models they want to print and pay the cost. The designers upload a copy of the already bought models and the printers print the 3D objects and transfer the money to the corresponding model creators.
Follow these steps to setup and run the application:
- Docker
- npm
- Node
- Hyperledger Composer
- to install composer cli
npm install -g composer-cli
- to install composer-rest-server
npm install -g composer-rest-server
- to install composer cli
- Clone the repo
- Setup Fabric
- Generate the Business Network Archive
- Deploy to Fabric
- Run the Application
- Generate a REST Server
- Stop Fabric
- Additional Resources
Clone the 3DPrinter-Composer
code locally. In a terminal, run:
git clone https://git.fortiss.org/nieves/3DPrinter-Composer.git
There is a bash script startApp.sh
that executes all the necessary steps in order to run the application.
Inside the root
directory run:
./startApp.sh
To stop the fabric run:
./stop.sh
These steps are described in detail below.
NOTE: The application is using the single BigchainDB node running at the fortiss network at the following IP and port: http://78.47.44.213:8209
Remove all previously created Hyperledger Fabric chaincode images:
docker rmi $(docker images dev-* -q)
Set Hyperledger Fabric version to v1.0:
export FABRIC_VERSION=hlfv1
All the necessary scripts are in the directory /fabric-tools
. Start fabric and create peer admin card:
cd fabric-tools/
./downloadFabric.sh
./startFabric.sh
./createPeerAdminCard.sh
Generate the Business Network Archive (BNA) file from the root
directory:
cd ../
mkdir dist
composer archive create -a dist/printer-use-case.bna --sourceType dir --sourceName .
The composer archive create
command will created a file called printer-use-case.bna
in the dist
folder.
First, install the composer runtime on the peer:
cd dist/
composer network install --card PeerAdmin@hlfv1 --archiveFile printer-use-case.bna
Deploy the business network on the peer and create a new participant, identity and an associated card for the network adminstrator:
composer network start --networkName printer-use-case --networkVersion 0.0.1 --card PeerAdmin@hlfv1 --networkAdmin admin --networkAdminEnrollSecret adminpw --file networkadmin.card
Import the network administrator identity card:
composer card import --file networkadmin.card
Ping the network to check that the business network has been deployed successfully:
composer network ping --card admin@printer-use-case
First, inside the angular-app
directory install the dependencies:
cd ../angular-app
npm install
To start the application run:
npm start
NOTE: The application is now running at: http://localhost:4200 We are using the single BigchainDB node running at the fortiss network at the following IP and port: http://78.47.44.213:8209
The application needs a REST server in order to communicate with the network. The generated API is connected to the blockchain and the business network.
- To start the REST server run:
composer-rest-server
-
Enter
admin@printer-use-case
as the card name. -
Select Always use namespaces when asked whether to use namespaces in the generated API.
-
Select No when asked whether to secure the generated API.
-
Select Yes when asked whether to enable event publication.
-
Select No when asked whether to enable TLS security.
The REST server is available at: http://localhost:3000/explorer/
To stop the fabric, run the following commands inside the fabric-tools
directory:
./stopFabric.sh
./teardownFabric.sh