This network tracks the booking, cancelling or checking out transactions of hotel rooms from the client to the Hotel listed in the network on a fabric blockchain.
Hotel
Client
Rooms
Order
Bookroom
Cancelroom
Durationcomplete
A Client
uses the application run by a consortium of Hotels
to book a Room
in any
of the listed Hotels
. The application submits a BookRoom
transaction which creates a
new Order
asset. The application also pays the amount to the Hotel
. While looking for
a Room
, the client can also see the availability as the Room
asset has a property to
show the availability. The applcation has two more transactions Cancelroom
and Durationcomplete
. In case the Client
wishes to cancel the order, he can publish it
through he transaction Cancelroom
. If the Client
is checking out, he can publish
it through Durationcomplete
transaction, so that the status of the room can be changed
from Booked to available.
Navigate to the online composer playground and copy the models file in the models.cto file, script to script.js and permissions to permissions.acl file. Navigate to Test tab and
then create new Client
and Hotel
. Create a new Room for the Hotel
and then Submit
a BookRoom
transaction.
{
"$class": "org.acme.hotelbooking.Bookroom",
"id": "",
"room": "resource:org.acme.hotelbooking.Room#4442",
"client": "resource:org.acme.hotelbooking.Client#4297",
"from": "2018-08-27T18:52:13.406Z",
"to": "2018-08-27T18:52:13.406Z",
"no_of_days": 0
}
This will Book the room and also transfer the funds from the client's balance to the Hotel's balance.
Next you can submit the transaction Cancelroom
which will cancel the room's Booking thus changing the room's status from Booked to available. Also note that there is no
refund policy in this application but it depends on the consortium of Hotels.
{
"$class": "org.acme.hotelbooking.Cancelroom",
"room": "resource:org.acme.hotelbooking.Room#6011",
"client": "resource:org.acme.hotelbooking.Client#5048",
"order": "resource:org.acme.hotelbooking.Order#5530"
}
Also if you haven't submitted a Cancelroom
transaction you can submit a Durationcomplete
transaction, thus changing the room's status from Booked to available.
{
"$class": "org.acme.hotelbooking.Durationcomplete",
"room": "resource:org.acme.hotelbooking.Room#5631",
"order": "resource:org.acme.hotelbooking.Order#0572"
}
Within this network permissions are outlines for the participants outlining what they can and can't do. The rules in the permissions.acl file explicitly ALLOW participants to perform actions. Actions not written for a participant in that file are blocked. For sake of simplicity there are no restricions added but permissions should be added.
To start the network on a fabric Blockchain, first make sure you have all the development pre-requisites installed. Check them on https://hyperledger.github.io/composer/latest/installing/development-tools.
After this go the fabric-dev-server folder and run the following commands to start a fabric network.
./startFabric.sh
./createPeerAdmin.sh
Now go the folder where you have cloned this repo and run the following commands with required options
composer network install
composer network start
composer card import
composer network ping
Next to start the composer rest server, type the following command
composer-rest-server
We have our rest server running on localhost:3000.
To run a simple angular application generated by Yeoman generator, look into the angular- client repository.
Note : A more sophisticated application with a node.js server and a angular client application in which our fabric blockchain is interacting with node.js server instead of angular application is in progress.