Skip to content

Commit 2a22897

Browse files
committed
wip: create book project complete
1 parent f10c39b commit 2a22897

21 files changed

+95848
-35891
lines changed

README.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Moka
2+
3+
This repository hosts the primary codebase for [Moka](https://moka-v2.vercel.app). A publishing and reading app for digital novels, poems, short-stories, comics and books of all types.
4+
5+
Code inspired by [Minsta](https://minsta-app.vercel.app).
6+
7+
## Introduction
8+
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.
9+
10+
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.
11+
12+
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.
13+
14+
Readers buy from and enjoy reading their favourite authors with the e-reader.
15+
16+
## Using Moka
17+
Visit the [website](https://moka-v2.vercel.app) in your browser and connect your testnet wallet.
18+
19+
### Publish & sell a book
20+
As a writer who wants to publish on Moka;
21+
##### Publish
22+
- Visit the [publisher page](https://testnet.mintbase.xyz/contract/mokastore.mintspace2.testnet/mint).
23+
- Add the details about your book
24+
- Set the "Amount to Mint" as 25 (that's the current maximum)
25+
- Set name, description and upload the book cover
26+
- Set custom tags that apply e.g fiction, non-fiction, comic, horror, sci-fi etc
27+
- 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.
28+
- Use the "Custom" section to add values for
29+
- "author" with the name of the author e.g "J.K Rowling" or "Stephen King" without quotes
30+
- "published" with the year it was published e.g "2023", "1993" without quotes
31+
- Click "Mint Me".
32+
##### Put book for sale
33+
- To list book copies for sale.
34+
- Open the token page
35+
- Click "Sell"
36+
- Set the price & number of copies to list (NOTE: make sure you set listing type as "Simple Sale")
37+
- Click "Make Listing"
38+
39+
### Read a book
40+
To read a book, first buy a book. Visit the [website](https://moka-v2.vercel.app) in your browser and connect your testnet wallet.
41+
##### Buy a book
42+
- Select a book
43+
- Click "Buy"
44+
- Approve the transaction in your wallet
45+
46+
##### Read a book
47+
After you purchase from the Moka store, visit [your book library](https://moka-v2.vercel.app/library) to read the book.
48+
49+
## Components
50+
To build this prototype I used the following tools and platforms.
51+
52+
1. Mintbase NFT store contract
53+
2. Mintbase SDK
54+
3. NEAR Blockchain
55+
4. NEAR BOS
56+
5. Arweave for permanent storage
57+
6. Next.js
58+
59+
### Mintbase NFT contract on NEAR with Storage on Arweave
60+
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.
61+
62+
### Mintbase JS
63+
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.
64+
65+
### NEAR BOS
66+
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.
67+
68+
### Future work
69+
To improve the project I plan to
70+
- improve the reading experience
71+
- encrypt file storage and also add other anti piracy features
72+
- implement more buying options like pay-per-page, monthly subscription, renting books, gifting books,
73+
- resale of owned books
74+
- 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.
75+
![Annotations mockup](book-anotation-mockup.jpg "Book anotation mockup")
76+
77+
78+
## Setting Up the Project
79+
80+
To start with this project:
81+
82+
1. Clone the repository.
83+
2. If you don't have `yarn` installed, run:
84+
85+
```bash
86+
npm install -g yarn
87+
```
88+
89+
3. Then, install the required dependencies:
90+
91+
```bash
92+
yarn install
93+
```
94+
95+
## Environment Variables
96+
97+
Refer to the **.env.example** file for the environment variables used in this project.
98+
99+
If you don't set up a `.env` file or environment variables with your provider, the project will retrieve values from the following files:
100+
101+
1. For CSS generation during build: `generate-css.js`
102+
2. For configuration variables: `src/constants.ts`
103+
3. For fallback metadata and text values: `src/fallback.ts`
104+
105+
## Local Development
106+
107+
To run the project locally, use:
108+
109+
```bash
110+
yarn dev
111+
```
112+
113+
## Updating Environment Variables
114+
115+
### Running Locally
116+
117+
If you're running your project locally, follow these steps to update your environment variables:
118+
119+
1. Save your changes in the `.env` file.
120+
2. Run `yarn dev` again to apply the updated environment variables.
121+
3. Reload the page to reflect the changes.
122+
123+
### Deployed on Vercel
124+
125+
If you have deployed your project on Vercel, follow these steps to update your environment variables:
126+
127+
1. Log in to your Vercel account.
128+
2. Navigate to the project settings for your deployed app.
129+
3. Update the environment variables in the Vercel dashboard.
130+
4. Trigger a redeployment of your app to apply the changes.
131+
132+
By following these steps, you can ensure that your project uses the updated environment variables.

contracts/contracts/FundProjectTokenFactory.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ contract FundProjectTokenFactory {
1010

1111
event TokenCreated(address indexed tokenAddress, address indexed treasury, address indexed creator);
1212

13-
constructor() {
14-
// Deploy the implementation contract once
15-
tokenImplementation = address(new FundProjectToken()); // dummy treasury
13+
constructor(address _implementation) {
14+
require(_implementation != address(0), "Invalid implementation");
15+
tokenImplementation = _implementation;
1616
}
1717

1818
function createToken(address treasuryAddress) external returns (address) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"_format": "hh-sol-dbg-1",
3+
"buildInfo": "..\\build-info\\d336ca7685c4aeb533e86049a36498ab.json"
4+
}

0 commit comments

Comments
 (0)