A modern, decentralized book marketplace built on Ethereum blockchain using Next.js, Hardnet, and MetaMask. BookVerse allows users to buy, sell, and manage books in a peer-to-peer marketplace with full ownership tracking and profit analytics.
- π Browse Books: View all available books in the store with beautiful card-based layout
- π Advanced Search & Filtering:
- Filter by genre (Fiction, Non-Fiction, Science Fiction, Fantasy, etc.)
- Search by book title or author name
- Filter by price range (min/max)
- π Purchase Books: Direct purchase from the store with instant ownership
- πͺ Marketplace: Buy books from other users at their listed prices
- π€ List Books for Sale: List your purchased books on the marketplace
- π° Track Sales & Profit: View your sales history with profit calculations
- β€οΈ Favorites/Whitelist: Add books to your favorites list
- π Book Viewer: Read dummy content for books you own
- π€ User Profile:
- View your book collection
- See total books owned, purchased, and total value
- Track active listings
- View sales history and profit
- β Add Books: Add new books to the store (restricted to Account #2)
- βοΈ Update Books: Edit book details (title, author, price, stock, image, genre)
- ποΈ Delete Books: Remove books from the store
- π Admin Dashboard:
- View total books listed in store
- Manage all books from Profile tab
- Track revenue from store sales
- See all sales history
- Node.js (v18 or higher recommended)
- npm or yarn
- MetaMask browser extension
- Git
-
Clone the repository
git clone https://github.com/varun3011/Book-Store-DAPP.git cd Book-Store-DApp -
Install dependencies
npm install
-
Set up Hardhat network
- The project uses Hardhat's local blockchain network
- No additional configuration needed
npx hardhat nodeThis will start a local Ethereum node on http://127.0.0.1:8545 with 20 test accounts pre-funded with 10,000 ETH each.
npx hardhat run scripts/deploy.ts --network localhostCopy the deployed contract address from the output. You'll need to update this in app/page.tsx (around line 806).
npm run devThe application will be available at http://localhost:3000
-
Add Hardhat Network to MetaMask:
- Network Name:
Hardhat Local - RPC URL:
http://127.0.0.1:8545 - Chain ID:
31337 - Currency Symbol:
ETH
- Network Name:
-
Import Test Accounts:
- Account #1 (Store Owner):
0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 - Account #2 (Book Manager/Admin):
0x70997970C51812dc3A010C7d01b50e0d17dc79C8 - Private keys are available in Hardhat's default accounts
- Account #1 (Store Owner):
-
Connect MetaMask: Click "Connect MetaMask Wallet" on the application
Book-Store-DApp/
βββ contracts/
β βββ BookStore.sol # Main smart contract
βββ scripts/
β βββ deploy.ts # Deployment script
βββ app/
β βββ page.tsx # Main frontend component
β βββ globals.css # Global styles
β βββ layout.tsx # App layout
βββ public/ # Static assets
βββ hardhat.config.js # Hardhat configuration
βββ package.json # Dependencies
- Add Books: Only Account #2 can add books to the store
- Update Books: Admin can modify book details (title, author, price, stock, image, genre)
- Delete Books: Admin can remove books from the store
- View Books: All users can browse and search books
- Browse books in "All Books" tab
- Click on a book card to open purchase modal
- Select quantity and confirm purchase
- Book ownership is recorded on blockchain
- Purchase a book from the store
- Go to "My Purchases" tab
- List your book for sale with custom price
- Other users can buy from your listing
- Track your sales and profit in Profile tab
- Access "Operations" tab (only visible to Account #2)
- Add new books with all details
- Manage all books from Profile tab
- View total revenue from store sales
- Update or delete any book
- Frontend: Next.js 13+, React, TypeScript
- Styling: Tailwind CSS, DaisyUI
- Blockchain: Ethereum, Hardhat
- Smart Contracts: Solidity
- Web3: Ethers.js
- Wallet: MetaMask
purchaseBook(uint256 _bookId, uint256 _quantity)- Purchase books from storelistForSale(uint256 _bookId, uint256 _price, uint256 _quantity)- List book on marketplacepurchaseFromUser(uint256 _bookId, address _seller, uint256 _quantity)- Buy from marketplaceupdateListing(uint256 _bookId, uint256 _newPrice, uint256 _newQuantity)- Update listingcancelListing(uint256 _bookId)- Cancel active listingaddToWhitelist(uint256 _bookId)- Add book to favoritesremoveFromWhitelist(uint256 _bookId)- Remove from favorites
addBook(...)- Add new bookupdateBook(...)- Update book detailsdeleteBook(uint256 _bookId)- Delete book
getBook(uint256 _bookId)- Get book detailsgetAllBooks()- Get all booksgetSalesHistory(address _user)- Get user's sales historygetTotalProfit(address _user)- Calculate total profitgetWhitelistedBooks(address _user)- Get user's favorites
- Modern Design: Glass morphism effects, gradient backgrounds, smooth animations
- Responsive Layout: Works on desktop, tablet, and mobile
- Card-based Display: Beautiful book cards with images
- Search & Filter: Advanced filtering by genre, text, and price
- Modal Interfaces: Clean modals for purchases and book viewing
- Toast Notifications: User-friendly feedback for all actions
- Access Control: Only Account #2 can add/update/delete books
- Ownership Verification: Blockchain-based ownership tracking
- Transaction Validation: All transactions verified on blockchain
- Price Tracking: Records original purchase price for profit calculation
- Sales History: Complete record of all sales with timestamps
- Profit Calculation: Automatic profit calculation (sell price - purchase price)
- Revenue Tracking: Admin can see total revenue from store sales
- Ownership Stats: Track total books owned, purchased, and value
- Ensure Hardhat node is running on port 8545
- Check MetaMask is connected to Hardhat Local network
- Verify contract address is updated in
app/page.tsx
- Ensure you have enough ETH in your account
- Check Hardhat node is running
- Verify MetaMask is unlocked
- Refresh the page
- Check browser console for errors
- Ensure contract is deployed and address is correct
This project is open source and available for educational purposes.
- ARYAN J PANDIT Email:- aryanpandit1718@csu.fullerton.edu CWID:- 815625769
- Dhrit T Patel Email:-dhritpatel2001@csu.fullerton.edu CWID:- 840720064
- DEV S VYAS Email:-devvyas16@csu.fullerton.edu CWID:-842783672
- VARUN PATEL Email:-varun3011@csu.fullerton.edu CWID:-845405406
- GitHub: @varun3011
- Built with Hardhat and Next.js
- Uses Ethers.js for blockchain interactions
- Styled with Tailwind CSS and DaisyUI