- Node >= v12
# Install Dependencies
npm install
# Compile contracts
./node_modules/.bin/truffle compile
# Run local development RPC instance
./node_modules/.bin/ganache-cli
# Run tests
./node_modules/.bin/truffle test
Administrator is the person which can add new books in library
Book consist of name, id and copies which is available in library of a given book.
Borrower is a user which can take a book from library. He can only take a 1 copy of book per book.
BookLedger contain one - one mapping of ids with books.
- Only Adminstrator can call this function.
- It is used to add books in library.
- It also autogenerate an id and assign it to book.
- _name: name of book. Name of book is also unique. So there will be no 2 books having same name
- _copies: total number of copies of a book included in library
- Only Adminstrator can call this function.
- It is used to add more copies of an existing book.
- _bookId: Id of book
- _copies: total number of copies of the book to add.
- It is a public function.
- It can only borrow a book which is available in the library
- User can only borrow 1 copy of book with given Id.
- Borrowing of book reduce the available copies of book by 1
- User cannot borrow books more than available copies of book with given id.
- id: id of a book present in library
- It is a public function.
- User can only return a book if it is borrowed by given user.
- Returning of book will increase available copies by 1.
- id: id of a book present in library
- It is a public function.
- Return an array of bookIds which given user can borrow ie.. only books which are not borrowed by user and books whose copies are available in the library
- It is a public function.
- Return an array of addresses of user who borrowed the book untill present
- id: id of a book present in library
- It is a public function.
- returns an name of book and available copies of given book
- id: id of a book present in library