Md Foysal Ahmed
Web3/Blockchain2025

ChainBooks

A blockchain-powered e-book marketplace built on NEAR Protocol, enabling users to browse, purchase, and instantly download curated e-books using cryptocurrency.

Next.jsTypeScriptReactSupabaseNEAR ProtocolTailwind CSSShadcn UI
ChainBooks

Project Overview

ChainBooks is a decentralized e-book marketplace built on NEAR Protocol. Users can browse a curated collection of books on blockchain, programming, AI, and design — then purchase them instantly using wNEAR cryptocurrency via PingPay.

The platform combines traditional e-commerce UX with blockchain-powered payments, offering a seamless way to buy books with crypto while maintaining full transparency and no middlemen.

Key Features


Technologies Used

Frontend

TechnologyPurpose
Next.js 16App Router, React Server Components
React 19Modern component-based UI
Tailwind CSS v4Utility-first responsive styling
shadcn/uiAccessible, production-ready components
Lucide ReactIcon library
TypeScriptEnd-to-end type safety

Backend & Blockchain

TechnologyPurpose
SupabasePostgreSQL database, Auth, Row-Level Security
PingPaywNEAR payment processing on NEAR Protocol
NEAR ProtocolBlockchain layer for trustless payments
WebhooksHMAC SHA256 verified payment confirmation

How It Works

  1. Browse — Explore the curated collection of e-books with detailed descriptions
  2. Purchase — Click "Buy with NEAR" and complete payment via PingPay checkout
  3. Download — After payment confirmation, PDF is instantly available in your dashboard

The entire payment flow settles on-chain via NEAR Protocol, ensuring transparency and security without intermediaries.


Architecture Highlights

Payment Flow

User clicks "Buy with NEAR"
  → POST /api/orders (creates PingPay session + pending purchase)
  → Redirect to PingPay hosted checkout
  → User completes wNEAR payment
  → PingPay webhook confirms payment (HMAC SHA256 verified)
  → Purchase status updated to "completed"
  → PDF available for download in dashboard

Database Design

Security


Challenges & Solutions

1. Blockchain Payment Integration

Challenge: Integrating NEAR Protocol payments into a traditional web app while maintaining a smooth UX.

Solution: Used PingPay as a payment abstraction layer, handling the complexity of blockchain transactions while providing a familiar checkout experience. The webhook-based verification ensures payments are confirmed on-chain before granting access.

2. Real-time Payment Status

Challenge: Users need immediate feedback after completing a crypto payment, but blockchain confirmations aren't instant.

Solution: Implemented a polling mechanism on the payment status page that checks verification every 3 seconds, with a 5-minute timeout. Combined with webhook processing, this provides near-instant confirmation for most transactions.


Results


Links


Built with Next.js 16, NEAR Protocol, Supabase, and PingPay.