No description
  • JavaScript 53%
  • Solidity 39.9%
  • CSS 3.8%
  • HTML 3.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
sripwoud 76d59c8390 Merge pull request #6 from r1oga/dependabot/npm_and_yarn/bl-1.2.3
build(deps): Bump bl from 1.2.2 to 1.2.3
2021-07-23 15:03:53 +02:00
client feat: Toggle operational status (front-end) 2019-03-15 00:44:08 +01:00
contracts fix: Add missing setOperatingStatus function to LibraryApp contract 2019-03-14 02:33:04 +01:00
migrations feat: Set up 2 initials contracts. Handle operational status 2019-03-12 16:25:17 +01:00
test test: Trade books and withdraw credited amount from contract 2019-03-13 11:53:32 +01:00
.gitignore feat: Set up 2 initials contracts. Handle operational status 2019-03-12 16:25:17 +01:00
Heritage Solidity Engineer JD.pdf Merge Applications into Master (#1) 2018-08-13 16:19:04 -07:00
LICENSE Applications (#2) 2018-09-10 12:23:52 -07:00
package-lock.json build(deps): Bump bl from 1.2.2 to 1.2.3 2021-07-23 13:02:07 +00:00
package.json feat: Init and wire up React front-end client. Install Drizzle 2019-03-14 01:25:54 +01:00
README.md Update README 2019-03-13 12:06:23 +01:00
truffle-config.js feat: Init and wire up React front-end client. Install Drizzle 2019-03-14 01:25:54 +01:00

A3 by Airbus Group - Solidity Engineer - Solidity Challenge

Solidity Smart Contracts to manage the inventory of a book library.

Initial Requirements

  1. The library has an owner and librarians.✔️
  2. The owner may add or remove librarians.✔️
  3. Only librarians may check books out to an address.✔️
  4. A book owner may trade the book to anyone else. ✔️
  • Only the owner of a book can put it on sale
  • Anyone can buy a book which is on sale
  1. Anyone may check in a book.✅
    I changed this requirement into anyone except librarians... because I found weird to let librarians check back in books to themselves.
  2. Librarians may add/remove books to the library. ✔️
  3. Track the history of the book's ownership. ✔️
    To fulfill this requirement I am using an array of Transfer structs within the Book struct.
  4. Record damage & repair for a book.✔️
    This is also covered by a book's Transfer struct.
  5. View book status/history. ✅
    For a given book, the view/get function returns all Book's parameters but only the last recorded transfer.
  6. Log relevant events. ✔️
  7. Use of the following tools/resource: ✔️
  • Truffle Framework
  • GitHub
  • Mocha/Chai
  • OpenZeppelin
  • npm
  1. Perform unit tests ✔️

Additional requirements

On top of the requirements which were already specified, I also fulfilled the following:
13. Separate contract data from app logic (libraryData.sol and libraryApp.sol) to ensure upgradability. In the case where business rules were to change, a new app contract would be deployed without modifying the data contract.
14. Control which app contracts can call the data contract (callerAuthorized modifier and proper migration set up). 15. Operational control: set a boolean flag (operational)to stop the contracts in case something goes wrong (setOperationalStatus()).
16. Follow a CRUD pattern to manage books. Credit Rob Hitchens
17. Follow security best practice for payments/transfer: don't push the transfers but let users pull/withdraw their credited amount.

Data structures

  • Tracks registered librarians: librarians mapping
  • Track books
    • Book struct
      • Track check out/in: checkedOut boolean
      • Track history of ownership and e.g damages: Transfer struct and Transfers[] array
    • books mapping
    • bookKeys hash keys array
  • Trade books
    • price property in Book struct
    • pattern: put book on sale, buy book, withdrawal

Getting Started

  1. Clone repository
  2. Install dependencies: npm install
  3. Run tests: npm run test

Further developments

  • Build front end (e.g with drizzle)
  • Make contract ready for prod: some variables (e.g withdrawals mapping) were deliberately left with a public visibility to ease unit testing. This should be changed.