Skip to content

aakash4dev/nextjs-ethereum-explorer

Repository files navigation

Ethereum Blockchain Explorer - Industrial Grade

A comprehensive, production-ready Ethereum blockchain explorer built with Next.js, MongoDB, and Web3.js. This industrial-grade explorer provides real-time blockchain indexing, comprehensive transaction tracking, address analytics, and a modern, professional user interface.

🌐 Live Demo: https://nextjs-ethereum-explorer.vercel.app/

Note: The live demo has sync disabled to manage database costs. For full functionality, run the explorer locally or deploy with your own database.


πŸš€ Quick Start

Prerequisites

  • Node.js (v18 or higher)
  • MongoDB (local or Atlas)
  • Ethereum RPC Endpoint (public RPC or your own node)

Installation

  1. Clone and install:

    git clone https://github.com/aakash4dev/nextjs-ethereum-explorer.git
    cd nextjs-ethereum-explorer
    npm install
  2. Configure environment:

    cp .example.env .env

    Edit .env with your settings:

    ETHEREUM_RPC_URL=https://ethereum-rpc.publicnode.com
    MONGODB_URI=mongodb://localhost:27017/ethereum_indexer
    START_BLOCK=23756000  # Recent block for faster sync
    INDEXER_BATCH_SIZE=10
    SYNC_INTERVAL=5000
  3. Setup MongoDB:

    Ubuntu/Debian:

    curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor
    echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
    sudo apt-get update && sudo apt-get install -y mongodb-org
    sudo systemctl start mongod && sudo systemctl enable mongod

    macOS:

    brew tap mongodb/brew
    brew install mongodb-community
    brew services start mongodb-community

    Windows: Download from MongoDB Download Center

    Or use MongoDB Atlas: See MongoDB Atlas setup guide

  4. Run the application:

    Terminal 1 - Frontend:

    npm run dev

    Terminal 2 - Indexer:

    npm run sync
  5. Verify it's working:

    curl http://localhost:3000/api/indexer
    curl http://localhost:3000/api/stats

Visit http://localhost:3000 to see the explorer!

Screenshots

Video Walkthrough

Walkthrough Video

Screenshots

Homepage

Homepage

Transactions List

Transactions List

Transaction Details

Transaction Details

Blocks List

Blocks List

Block Details

Block Details

✨ Features

  • Real-time Blockchain Indexing - Continuous synchronization with configurable start block
  • Comprehensive Data Tracking - Blocks, transactions, addresses, and contract interactions
  • Advanced Search - Search by block number, transaction hash, or Ethereum address
  • Address Analytics - Balance tracking, transaction history, and statistics
  • Modern UI - Professional, dark-themed interface with real-time stats
  • Production Ready - Robust error handling, batch processing, and database optimization

See ROADMAP.md for detailed features and future plans.


πŸ”§ Configuration

Variable Description Default
START_BLOCK Block number to start indexing from 0
INDEXER_BATCH_SIZE Blocks processed per sync cycle 10
SYNC_INTERVAL Milliseconds between sync cycles 5000
ETHEREUM_RPC_URL Ethereum RPC endpoint Required
MONGODB_URI MongoDB connection string Required

πŸš€ Deployment

Vercel (Frontend)

  1. Push code to GitHub
  2. Import project in Vercel
  3. Add environment variables in Settings β†’ Environment Variables:
    • MONGODB_URI (MongoDB Atlas connection string)
    • ETHEREUM_RPC_URL
    • START_BLOCK
    • INDEXER_BATCH_SIZE
    • SYNC_INTERVAL
  4. Deploy

Note: Vercel uses environment variables from its dashboard, not from .env file.

Background Sync Service

Deploy the sync service separately (VPS, AWS EC2, etc.):

pm2 start src/lib/sync-service.js --name ethereum-indexer
pm2 logs ethereum-indexer
pm2 save
pm2 startup

πŸ› Troubleshooting

Indexer Not Syncing

# Check MongoDB
sudo systemctl status mongod
mongosh mongodb://localhost:27017/ethereum_indexer --eval "db.stats()"

# Check sync status
curl http://localhost:3000/api/indexer

Reset Database

npm run reset-db
# Or manually:
mongosh mongodb://localhost:27017/ethereum_indexer --eval "db.dropDatabase()"

"Indexer is already running" (Stuck)

mongosh mongodb://localhost:27017/ethereum_indexer --eval "db.indexerstates.updateOne({ key: 'sync_state' }, { \$set: { isSyncing: false } })"
npm run sync

For detailed troubleshooting, see ARCHITECTURE.md.


πŸ“š Documentation


πŸ› οΈ Tech Stack

  • Frontend: Next.js 15 (App Router), React 19, Tailwind CSS
  • Backend: Next.js API Routes
  • Database: MongoDB with Mongoose
  • Blockchain: Web3.js v4
  • Icons: React Icons

πŸ‘€ About & Contact

Aakash Singh Rajput

Aakash Singh Rajput - Blockchain Developer

Website | GitHub | LinkedIn | Twitter

Custom Blockchain Explorers

This project demonstrates industrial-grade blockchain indexing and exploration.

Note: While this repository provides a robust and functional foundation, it is intended as a showcase of core capabilities. It is not a fully-fledged, enterprise-ready production deployment out of the box.

I am available for paid engagement to develop fully customized, production-grade blockchain explorers and indexers tailored to your specific requirements, including:

  • Custom EVM-compatible chains (Polygon, BSC, Avalanche, etc.)
  • Layer 2 solutions and validiums
  • Private permissioned blockchain networks
  • Enterprise-grade security and infrastructure setup

πŸ“„ License

This project is licensed under the MIT License.

Copyright

Copyright (c) 2024 Aakash Singh Rajput

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


🀝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines on how to contribute to this project.


πŸ™ Acknowledgments

About

A functional and clean block explorer for Ethereum, built with Next.js (App Router), MongoDB, and Web3.js.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors