A Next.js-based blockchain explorer for the Mintlayer network, providing comprehensive insights into blocks, transactions, addresses, pools, and delegations on both mainnet and testnet.
- Block Explorer: Browse blocks, transactions, and addresses
- Pool Management: View staking pools and delegation information
- Token Support: Explore tokens and NFTs on the Mintlayer network
- Responsive Design: Mobile-friendly interface built with Tailwind CSS
- Node.js: Version 18.x or higher
- npm: Version 8.x or higher (comes with Node.js)
git clone https://github.com/mintlayer/explorer.git
cd explorernpm installCreate a .env.local file in the root directory (or copy from .env):
cp .env .env.localConfigure the following environment variables:
# Network configuration (testnet or mainnet)
NETWORK=testnet
# Server URL for the application
SERVER_URL=http://localhost:3000# Override default API URL (optional)
NODE_API_URL=
# CoinMarketCap API key for price data (optional)
CMC_API_KEY=your_cmc_api_key_here
# Basic authentication (optional, format: username:password)
BASIC_AUTH=
# ERC20 data server URL (optional)
ER20_DATA_SERVER_URL=https://token.api.mintlayer.org/apiPostgreSQL is now the primary explorer cache for:
- pools and delegations
- pool daily statistics
- latest blocks
- latest transactions
- tokens
- NFTs
Configure one of these variables:
DATABASE_URL=postgres://postgres:postgres@localhost:5432/mintlayer_explorer
# or
POSTGRES_URL=postgres://postgres:postgres@localhost:5432/mintlayer_explorerOptional cache controls:
EXPLORER_RECENT_TRANSACTIONS_LIMIT=100
EXPLORER_RECENT_BLOCKS_LIMIT=100
POSTGRES_POOL_SIZE=10If Postgres is not configured, API routes still work in fallback mode, but the fast DB first path is disabled.
The cache is now split into two workers:
npm run sync:recent-chain
npm run sync:catalogUse the fast worker for blocks/transactions and the heavier worker for pools/statistics/tokens/NFT. The legacy command still exists:
npm run start:workerWorkers:
npm run sync:recent-chainupdates latest transactions and latest blocks in PostgreSQLnpm run sync:catalogupdates pools, delegations, pool statistics, tokens and NFT indexesnpm run start:workercurrently aliases the catalog worker for backward compatibility
Note: Run this periodically to keep pool data up-to-date. Consider setting up a cron job for production environments.
npm run devOpen http://localhost:3000 to view the explorer in your browser.
# Development
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
# Data Management
npm run sync:recent-chain # Fast sync for latest blocks and transactions
npm run sync:catalog # Heavy sync for pools, stats, tokens and NFT
npm run start:worker # Backward-compatible catalog sync
npm run sync:explorer-cache # Alias for the catalog sync worker
# Code Quality
npm run lint # Run ESLint
npm run test # Run Jest testsexplorer/
βββ src/
β βββ app/ # Next.js App Router pages
β β βββ (homepage)/ # Homepage components
β β βββ _components/ # Shared UI components
β β βββ api/ # API routes
β β βββ address/ # Address pages
β β βββ block/ # Block pages
β β βββ pool/ # Pool pages
β β βββ ...
β βββ config/ # Configuration files
β βββ hooks/ # React hooks
β βββ lib/ # Utility libraries
β βββ providers/ # React context providers
β βββ utils/ # Utility functions
βββ workers/ # Background workers
β βββ pools.js # Catalog sync worker
β βββ recent-chain.js # Fast recent blocks/transactions sync
β βββ lib/ # Shared worker logic
βββ public/ # Static assets
βββ .env # Environment variables template
βββ PostgreSQL # Primary explorer cache
docker build -t mintlayer-explorer .docker run -p 3000:3000 \
-e NETWORK=testnet \
mintlayer-explorerCreate a docker-compose.yml:
version: '3.8'
services:
explorer:
build: .
ports:
- "3000:3000"
environment:
- NETWORK=testnet
- SERVER_URL=http://localhost:3000
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/mintlayer_explorer
volumes:
- ./data.db:/usr/src/app/data.dbThe explorer supports two networks:
- Testnet (default):
NETWORK=testnet - Mainnet:
NETWORK=mainnet
Network configuration affects:
- API endpoints used
- Address format validation
- UI color scheme
- Pool ID prefixes
By default, the application uses official Mintlayer API servers:
- Testnet:
api-server-lovelace.mintlayer.org - Mainnet:
api-server.mintlayer.org
Override with NODE_API_URL environment variable if needed.
Run the test suite:
npm testThe project uses Jest for testing with TypeScript support.
npm run buildnpm startSet up separate cron jobs for fast-moving chain data and heavier catalog data:
# Update recent blocks and transactions every minute
* * * * * cd /path/to/mintlayer-explorer && npm run sync:recent-chain
# Update pools, pool stats, tokens and NFT every 10 minutes
*/10 * * * * cd /path/to/mintlayer-explorer && npm run sync:catalog-
Cached explorer data not showing
- Set
DATABASE_URLorPOSTGRES_URL - Run
npm run sync:recent-chainandnpm run sync:catalogto populate PostgreSQL - Check network connectivity to Mintlayer API servers
- Set
-
PostgreSQL connection issues
- Verify the database is reachable from the app container or host
- Confirm credentials in
DATABASE_URL
-
WASM module issues
- The project includes pre-built WASM binaries
- If issues persist, check the
src/utils/mintlayer-crypto/pkg/directory
-
Environment variables not loading
- Ensure
.env.localexists and contains required variables - Restart the development server after changing environment variables
- Ensure
- Critical explorer data is cached in PostgreSQL to reduce API calls
- Consider adding a scheduler or queue for continuous cache refresh
- Use CDN for static assets in production
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature - Commit changes:
git commit -am 'Add new feature' - Push to branch:
git push origin feature/new-feature - Submit a pull request
The project uses:
- ESLint for code linting
- Prettier for code formatting
- Husky for git hooks
- lint-staged for pre-commit checks
This project is licensed under the terms specified in the LICENSE file.