Production-grade blockchain explorer and indexer for GLIN Network. Built with Next.js (frontend) and Rust + Axum (backend), following the Ethereum architecture pattern (like Etherscan/Blockscout).
This is a monorepo containing both frontend and backend:
glin-explorer/
βββ frontend/ # Next.js explorer UI
βββ backend/ # Rust workspace (indexer, API, verifier)
βββ docker-compose.yml # Run all services
Following the Ethereum pattern (Etherscan uses web3.js, we use glin-sdk-rust):
- Indexer - Real-time blockchain indexing using
glin-indexerSDK - API - REST API with Axum reading from PostgreSQL
- Verifier - Contract source code verification using
glin-contractsSDK - DB - Shared database layer (models, migrations)
- Blockchain explorer UI
- Direct RPC queries (via Polkadot.js)
- Enhanced data from backend API
# Copy environment file and configure
cp .env.example .env
# Edit .env with your settings (RPC_URL, passwords, etc.)
# Start backend services (postgres, redis, indexer, api, verifier)
docker-compose up -d
# View logs
docker-compose logs -f
# Stop all services
docker-compose downBackend services will be available at:
- API: http://localhost:3001
- PostgreSQL: localhost:5432
- Redis: localhost:6379
Then run the frontend separately:
cd frontend
npm install
npm run devFrontend will be available at http://localhost:3000
Install required tools:
# Install sqlx-cli for database migrations
cargo install sqlx-cli --no-default-features --features postgres
# Ensure PostgreSQL and Redis are running
# On Ubuntu/Debian:
sudo apt install postgresql postgresql-contrib redis-server
sudo systemctl start postgresql redis-server
# On macOS (with Homebrew):
brew install postgresql redis
brew services start postgresql rediscd backend
# Copy environment
cp .env.example .env
# Edit .env with your settings
# Run database migrations
cargo sqlx migrate run
# Run services (in separate terminals)
cargo run --bin indexer # Start indexer
cargo run --bin api # Start API server
cargo run --bin verifier # Start verifiercd frontend
# Install dependencies
npm install
# Copy environment
cp .env.example .env.local
# Edit .env.local
# Run development server
npm run devbackend/
βββ Cargo.toml # Workspace root
βββ crates/
β βββ db/ # Database layer
β β βββ migrations/ # SQL migrations
β β βββ src/
β β βββ models.rs # sqlx models
β β βββ lib.rs
β β
β βββ indexer/ # Block indexer (binary)
β β βββ src/main.rs # Uses BlockStream, EventDecoder
β β
β βββ api/ # REST API (binary)
β β βββ src/main.rs # Axum server
β β
β βββ verifier/ # Contract verifier (binary)
β βββ src/main.rs # Uses ContractVerifier SDK
Uses glin-sdk-rust v0.2.0:
// Indexer uses SDK utilities
use glin_indexer::{BlockStream, EventDecoder, ExtrinsicParser};
use glin_client::create_client;
let client = create_client("wss://testnet.glin.ai").await?;
let decoder = EventDecoder::new(&client)?;
let parser = ExtrinsicParser::new();
let mut stream = BlockStream::subscribe_finalized(&client).await?;
while let Some(block) = stream.next().await {
// Index to PostgreSQL...
}PostgreSQL tables:
blocks- Indexed blocksextrinsics- Transactionsevents- Blockchain eventscontracts- Deployed contractscontract_verifications- Verification requestsaccounts- Cached account balances
Migrations: backend/crates/db/migrations/
GET /api/health
GET /api/blocks/latest
GET /api/blocks/:number
GET /api/extrinsics/:hash
GET /api/accounts/:address
GET /api/accounts/:address/extrinsics
GET /api/contracts/:address
- π Global search (blocks, transactions, accounts)
- π¦ Block explorer with extrinsics and events
- π³ Transaction details with event decoding
- π€ Account explorer with balance and history
- β‘ Real-time updates via WebSocket
- π Tasks - TaskRegistry pallet integration
- π₯οΈ Providers - ProviderStaking pallet
- π Leaderboard - TestnetPoints tracking
- π° Rewards - RewardDistribution pallet
cd backend
# Run tests
cargo test
# Run specific service
cargo run --bin indexer
cargo run --bin api
cargo run --bin verifier
# Check code
cargo clippy
cargo fmtcd frontend
# Development
npm run dev
# Build
npm run build
npm start
# Lint
npm run lint# Backend
docker build -t glinscan-backend ./backend
# Frontend
docker build -t glinscan-frontend ./frontenddocker-compose -f docker-compose.yml -f docker-compose.prod.yml up -dDATABASE_URL=postgres://glin:password@localhost:5432/glinscan
REDIS_URL=redis://localhost:6379
RPC_URL=wss://testnet.glin.ai
API_HOST=0.0.0.0
API_PORT=3001
RUST_LOG=info,glinscan=debug
VERIFIER_WORKSPACE=/tmp/glin-verifierNEXT_PUBLIC_RPC_ENDPOINT=wss://testnet.glin.ai
NEXT_PUBLIC_API_URL=http://localhost:3001
NEXT_PUBLIC_CHAIN_NAME=GLIN Testnet
NEXT_PUBLIC_TOKEN_SYMBOL=tGLIN
NEXT_PUBLIC_TOKEN_DECIMALS=18Deploy 3 services:
- Indexer service
- API service
- Verifier service
Plus PostgreSQL and Redis add-ons.
cd frontend
vercel --prodOr connect GitHub repo to Vercel dashboard.
- glin-sdk-rust - Rust SDK (utilities library)
- glin-chain - Substrate blockchain
- glin-forge - Smart contract CLI
Contributions welcome! Please see CONTRIBUTING.md.
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing) - Open Pull Request
Apache 2.0 - see LICENSE for details.
- π Website: glin.ai
- π Docs: docs.glin.ai
- π¬ Discord: discord.gg/glin-ai
- π¦ Twitter: @glin_ai