/near-book-store

Simple Bookstore on Near Blockchain

Primary LanguageTypeScript

near-book-store

This project is a simple bookstore on Near blockchain. Users can publish their book and buy others books, and review a book by writing comments about it.

Installation

git clone https://github.com/muammer-yilmaz/near-book-store
cd near-book-store
yarn

How to Use Bookstore Smart Contract

First login to your account using near cli

near login

Build and deploy the smart contract.

yarn dev

Export the development account to the $CONTRACT

export CONTRACT=YOUR_DEV_ACCOUNT_HERE

Create a Book.

near call $CONTRACT createBook '{"name": "Book Name", "desc": "Book Description", "price" : 5}' --accountId muammer-yilmaz.testnet

List All Books

near call $CONTRACT getBooks '{"start": 0, "limit" : 10}' --accountId muammer-yilmaz.testnet

Buy a Book

near call $CONTRACT buyBook '{"id": "Book id"}' --accountId muammer-yilmaz.testnet --deposit 5

Read a Book

near call $CONTRACT getChapters '{"id": "Book id"}' --accountId muammer-yilmaz.testnet

Add a chapter to your book

near call $CONTRACT addChapter '{"id": "Book id", "content": "Chapter Content"}' --accountId muammer-yilmaz.testnet

Add a comment to a book

near call $CONTRACT addComment '{"id": "Book id", "comment": "Your Comment"}' --accountId muammer-yilmaz.testnet

Get all comment of a book

near call $CONTRACT getComments '{"id": "Book id"}' --accountId muammer-yilmaz.testnet