Book Management is a smart contract which works as a library. It contains a database of books. The following functionalities can be added:
- Create a book with details like:
- ID of the book
- Name of the book
- Author of the book
- Department to which the book belongs to
-
View all the books stored on chain
-
Query a particular book though ID of the book.
To run the project locally, follow the below steps:
- Make sure you have installed Node.js >= 12
- Make sure you have installed NEAR CLI :
npm i -g near-cli
- Login to your NEAR account.
- If you don't have a NEAR account , create it at [https://wallet.testnet.near.org/]
- Configure NEAR CLI to authorize your testnet account:
near login
- Clone this repository
- In the terminal , navigate to the project folder, to install the dependencies and run
yarn
- Run
yarn build
to build the smart contract. Look at package.json folder to see all the command that can be executed with yarn. - Run
yarn deploy
to deploy the smart contract to the development server that was built in the previous step. This will return the Txn ID of the deployed contract along with a link to near explorer to see various statistics of the deployed contract.
The following commands will allow you to interact with NEAR CLI and the deployed smart contract's methods:
near call $CONTRACT newBook '{"bookId": "string","bookName": "string","author": "string","department": "string"}' --account-id <Enter your account id>
Insert the data in place of "string" mentioned in the command of the method.
The contract details will be available in the folder named 'neardev'->'dev-account'
near view $CONTRACT seeBooks '{}'
near call $CONTRACT queryBook '{"bookID" : "string"}' --account-id <Enter your account id>
Insert the ID of the book in place of string in above command.
The contract can be used as a Blockchain based Library application for storing books on chain with other related info after amending in the contract.