An Ethereum based decentralized room booking application.
Two companies (i.e. Coke, Pepsi) are sharing an office building. They are competitors and they don't trust each other. Companies will host a number of business partners in the building for an event. In order to optimize space utilization, they have decided to set-up a joint booking system where any user can book one of the 20 meeting rooms available, 10 from each company (C01, C02, ..., C10 and P01, P02, ...., P10).
The booking system has the following functionalities:
- Users can see meeting rooms availability
- Users can book meeting rooms by the hour (first come first served)
- Users can cancel their own reservations
- NodeJs: ^16.13.2
- NPM: ^8.1.2
- MetaMask: ^10.9.3
- Go to client folder:
cd client
- Install dependencies:
npm install
- Follow the MetaMask guidelines to add a custom network RPC for the local blockchain:
- Network name: Ganache
- New RPC URL: http://localhost:8545
- Chain ID: 1337
- Admin account's address is hard-coded in the configuation and you have to import it in your wallet to use the admin panel. Follow the steps here and import the following private key:
0xa6caff9838f6942575eacd4bdbf60edb40932d7926abaeed9016838f66c94c63
- Create at least 2 other accounts on MetaMask, name the accounts "Coke Employee" and "Pepsi Employee" to differentiate them from admin's account.
- Run start script:
npm start
This will start local blockchain (Ganache) on port 8545, compile / deploy contracts and run the development server. It will take some time. If you have any conflict with the port number, you can change it in truffle-config file. After running the development server, you will be redirected to http://localhost:3000.
- You can read a short overview of different parts of the application on the start page.
- First you have to add employee wallets, this will grant them permission to book the meeting rooms.
- Go to the "Admin Panel".
- Click on "Connect with MetaMask" button.
- Select the admin account that you have imported previously and click on "Connect".
- If you get an
Internal JSON-RPC error
from MetaMask, just change the network to any other one, then switch back to Ganache. It should resolve the issue. - Select the company in the dropdown menu and enter Coke/Pepsi employee's Ethereum address in the input field.
- Click on "Add Employee" to whitelist the employee's address. You can remove it later by clicking on "Remove employee".
- Confirm the transaction, it takes some time to execute (~= 10sec). After the execution you will be notified by a toaster.
- Switch to one of the employees MetaMask account, either in the same browser or in a different instance.
- Go to his/her company's booking page and connect his/her wallet.
- Select a room to display time slots, book any time slot that you want.
- Repeat the process wiht other employee(s).
When you restart the blockchain, you have to reset all MetaMask accounts you used before as explained here. If you forget to do it, all your transactions will stuck and displayed as "pending". The reason is that account nonces are reset when the blockchain restarts and MetaMask doesn't know about it. Alternatively, you can use custom nonce is MetaMask, as explained here.