Table of Contents
Books have a great place in our lives. The library system will also change in the developing world. I thought about how this process would be on BlockChain. And I came to this conclusion:
An application where you pay as much as the number of books you read.
You can find the link of the loom video and Patika at the bottom.
- Create books with book name, author name, genre, description etc. fields. Then may modify, inactivate them.
- EDetermines and creates membership types.
- Creates membership, buy subscription types so buys the right to read books. Also may checks/list books, account details.
Name | Type |
---|---|
owner | AccountId |
author | String |
bookName | String |
description | String |
genre | String |
country | String |
isActive | bool |
createdDate | Timestamp |
modifiedDate | Timestamp |
deletedDate | Timestamp |
Name | Type |
---|---|
owner | AccountId |
subscriptionType | i32 |
remainingReadingBookCount | i32 |
CreatedDate | Timestamp |
ModifiedDate | Timestamp |
Name | Type |
---|---|
owner | AccountId |
typeCode | String |
price | Money |
readingBookCount | i32 |
isActive | bool |
CreatedDate | Timestamp |
ModifiedDate | Timestamp |
DeletedDate | Timestamp |
yarn
yarn build:release
near dev-deploy ./build/release/simple.wasm
export CONTRACT=<AccountId>
echo $CONTRACT
near create-account <subAccName1>.<AccountName>.testnet --masterAccount <AccountName>.testnet --initialBalance 10
near create-account <subAccName2>.<AccountName>.testnet --masterAccount <AccountName>.testnet --initialBalance 10
near state <subAccName1>.<AccountName>.testnet
near state <subAccName2>.<AccountName>.testnet
near state <AccountName>.testnet
near send <AccountName>.testnet <subAccName1>.<AccountName>.testnet 10
near delete <subAccName1>.<AccountName>.testnet <AccountName>.testnet
near delete <subAccName2>.<AccountName>.testnet <AccountName>.testnet
This window is used to compile, deploy and control the contract
-
Environment
export CONTRACT= # depends on deployment export OWNER= # any account you control and create, add books and subscription types export USER= # any account buy subscription to reading books # for example # export CONTRACT=dev-1650345345591-4501142324234 # export OWNER=your-account-here.testnet # export USER=sub1.your-account-here.testnet
-
Commands
Owner scripts
1.dev-deploy.sh # cleanup, compile and deploy contract 2.create-subaccounts.sh # generate a summary report of the contract state 3.adminRole.sh 6.report.sh
Public scripts
4.userRole.sh 5.readBook.sh
Details | How to Call |
---|---|
Initializing | near call $CONTRACT init --accountId your-account-here.testnet |
Adding Book | near call $CONTRACT addBook '{"author":"Suzanne Collins","bookName":"The Hunger Games","description":"The first book in The Hunger Games series","genre":"Adventure","country":"USA"}' --accountId your-account-here.testnet |
Modifying Book | near call $CONTRACT modifyBook '{"bookId":0,"author":"Suzanne Collins","bookName":"Catching Fire","description":"The second book in The Hunger Games series","genre":"Adventure","country":"USA"}' --accountId your-account-here.testnet |
Inactivating Book | near call $CONTRACT inactivateBook '{"bookId":0}' --accountId your-account-here.testnet |
Getting All Books | near view $CONTRACT getAllBooks |
Getting Books With Book Id Parameter | near view $CONTRACT getBooksByBookId '{"bookId":0}' |
Getting Books With Author Name Parameter | near view $CONTRACT getBooksByAuthorName '{"authorName":"Suzanne Collins"}' |
Getting Books With Book Name Parameter | near view $CONTRACT getBooksByBookName '{"bookName":"The Hunger Games"}' |
Getting Books With Genre Parameter | near view $CONTRACT getBooksByGenreName '{"genre":"Literature"}' |
Getting Books With Country Parameter | near view $CONTRACT getBooksByCountryName '{"country":"TR"}' |
Creating Subscriber | near call $CONTRACT createSubscriber --accountId sub1.your-account-here.testnet |
Buying Subscription | near call $CONTRACT buySubscription '{"subscriberId":0,"subscriptionTypeId":0}' --accountId sub1.your-account-here.testnet --deposit 3 |
Read Book | near call $CONTRACT readBook '{"subscriberId":0,"bookId":0}' --accountId sub1.your-account-here.testnet |
Getting All Subscribers | near view $CONTRACT getAllSubscribers |
Getting Subscribers With Subscriber Id Parameter | near view $CONTRACT getSubscribersBySubscriberId '{"subscriberId":0}' |
Getting Subscribers With Account Id Parameter | near view $CONTRACT getSubscribersByAccountId '{"AccountId":"sub1.your-account-here.testnet"}' |
Adding Subscription Type | near call $CONTRACT addSubscriptionType '{"typeCode":"Basic","price":"500000000000000000000000","readingBookCount":500}' --accountId your-account-here.testnet |
Modifying Subscription Type | near call $CONTRACT modifySubscriptionType '{"subscriptionTypeId":3,"typeCode":"Old Type MODIFIED","price":"100000000000000000000000","readingBookCount":100}' --accountId your-account-here.testnet |
Inactivating Subscription Type | near call $CONTRACT inactivateSubscriptionType '{"subscriptionTypeId":0}' --accountId your-account-here.testnet |
Getting All Subscription Type | near view $CONTRACT getAllSubscriptionTypes '{}' |
Getting All Subscription Type By Type Id | near view $CONTRACT getSubscriptionTypesByTypeID '{"subscriptionTypeId":2}' |