Fully decentralized blockchain based calendar.
- Owner can create companies and assign rooms to them.
- Owner can create employees and assign them to companies.
- Employees can book a room for a given day slot.
- Employees can unbook their own booking.
- This is my first ever Solidity smart contract, please don't be too picky on the data structure and the code, I still need to learn the best practices and this was a complete discovery.
- I went with a simple CRUD data structure and the same contract owns the data, there's no proxy to a data store only contract.
- To develop the contract itself I went with TDD using Hardhat and then deployed on the Ropsten testnet to interract with the UI I built.
- Clone the repository
- Create a
.env
and fill it according to.env.example
- Run
yarn && yarn deploy
copy the contract address and add it toweb/.env
- Run
cd web && yarn dev
open your browser onhttp://localhost:3000
and voilà!
getCompanies()
->{ id: string; name: string }[]
getEmployees()
->{ addr: string; name: string, companyId: string }[]
getRooms()
->{ id: string; companyId: string }[]
getBookedSlots()
->{ slotId: string; roomId: string; bookedBy: string; }[]
addComapny(name: string)
removeCompany(id: string)
addEmployee(name: string, companyId: string)
removeEmployee(addr: string)
addRoom(name: string, companyId: string)
removeRoom(id: string)
bookSlot(roomId: string, slotId: string)
unbookSlot(roomId: string, slotId: string)
- The UI is built with React, ant.design and tailwindcss.
- For the deployment I went with fleek which is linked to the repository and auto-deploys new commits to IPFS network.
- ipfs://Qmdzg1NENbwdh67qQVc1wi7gp6MWfQuugJtuL8XsF5eVV7
- https://silent-math-4212.on.fleek.co/
/
-> connect to Metamask/admin
-> administration interface to create companies, employees and rooms/calendar
-> calendar interface to book and unbook slots for employees
- When switching profile into Metamask the contract is not updated, you must refresh the page
- Reloading the page doesn't save the last connected user
- Use multicall contract to fetch data for the UI
- The contract data and logic are stored in the same, this is a bad pattern. If you want to change your contrac logic you would have to migrate the data also.
- Use external storage contract (https://github.com/fravoll/solidity-patterns/blob/master/docs/eternal_storage.md)
- Use a proxy contract pattern (https://github.com/fravoll/solidity-patterns/blob/master/docs/proxy_delegate.md)