This repository hosts the primary codebase for Moka. A publishing and reading app for digital novels, poems, short-stories, comics and books of all types.
Code inspired by Minsta.
When the Gutenberg press was invented, it changed the way stories were told and knowledge was shared. It meant that words weren't exclusive to a few people but was available to anyone anywhere.
Printed books are still sold today, however, digital books are more widely adopted by readers. The challenge with digital books is their easy duplicity leaving writers with few ways to make money off them.
Moka is changing the narrative around digital books, writers publish their works and are guaranteed to make money because they can sell cryptographically secure copies of their books (NFTs) directly to their readers.
Readers buy from and enjoy reading their favourite authors with the e-reader.
Visit the website in your browser and connect your testnet wallet.
As a writer who wants to publish on Moka;
- Visit the publisher page.
- Add the details about your book
- Set the "Amount to Mint" as 25 (that's the current maximum)
- Set name, description and upload the book cover
- Set custom tags that apply e.g fiction, non-fiction, comic, horror, sci-fi etc
- Use the "Forever Document" section to upload the ebook file, it must be in EPUB format. Rename the file to "file-name.epub.pdf" because the upload only accepts PDFs. This will be updated in newer versions.
- Use the "Custom" section to add values for
- "author" with the name of the author e.g "J.K Rowling" or "Stephen King" without quotes
- "published" with the year it was published e.g "2023", "1993" without quotes
- Click "Mint Me".
- To list book copies for sale.
- Open the token page
- Click "Sell"
- Set the price & number of copies to list (NOTE: make sure you set listing type as "Simple Sale")
- Click "Make Listing"
To read a book, first buy a book. Visit the website in your browser and connect your testnet wallet.
- Select a book
- Click "Buy"
- Approve the transaction in your wallet
After you purchase from the Moka store, visit your book library to read the book.
To build this prototype I used the following tools and platforms.
- Mintbase NFT store contract
- Mintbase SDK
- NEAR Blockchain
- NEAR BOS
- Arweave for permanent storage
- Next.js
Mintbase provides audited smart contracts deployed on NEAR that helps anyone create and sell NFTs easily. Mintbase's V2 contracts were used with Arweave as data storage.
On the frontend, the MintbaseJS SDK was used to query and interact with the NFT data on chain. Payment, transfer, verifying ownership and asserting provenance through the contracts.
For writers or publishers, I deployed the publishing app to BOS and it allows writers to publish their books on a fully decentralized frontend layer. That way, they always know what to expect and not have the rules suddenly change.
To improve the project I plan to
- improve the reading experience
- encrypt file storage and also add other anti piracy features
- implement more buying options like pay-per-page, monthly subscription, renting books, gifting books,
- resale of owned books
- permanent book annotations. Just like with physical books, where you can highlight passages, make doodles, notes or whatever and it becomes a permanent part of your copy, this is similar where the metadata for a particular book can be updated and it'll be transferred with that book if it's ever resold or transferred.
To start with this project:
-
Clone the repository.
-
If you don't have
yarn
installed, run:npm install -g yarn
-
Then, install the required dependencies:
yarn install
Refer to the .env.example file for the environment variables used in this project.
If you don't set up a .env
file or environment variables with your provider, the project will retrieve values from the following files:
- For CSS generation during build:
generate-css.js
- For configuration variables:
src/constants.ts
- For fallback metadata and text values:
src/fallback.ts
To run the project locally, use:
yarn dev
If you're running your project locally, follow these steps to update your environment variables:
- Save your changes in the
.env
file. - Run
yarn dev
again to apply the updated environment variables. - Reload the page to reflect the changes.
If you have deployed your project on Vercel, follow these steps to update your environment variables:
- Log in to your Vercel account.
- Navigate to the project settings for your deployed app.
- Update the environment variables in the Vercel dashboard.
- Trigger a redeployment of your app to apply the changes.
By following these steps, you can ensure that your project uses the updated environment variables.