Skip to content

glin-ai/glin-explorer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GLIN Explorer

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).

License Next.js Rust

πŸ—οΈ Architecture

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

Backend Services (Rust)

Following the Ethereum pattern (Etherscan uses web3.js, we use glin-sdk-rust):

  1. Indexer - Real-time blockchain indexing using glin-indexer SDK
  2. API - REST API with Axum reading from PostgreSQL
  3. Verifier - Contract source code verification using glin-contracts SDK
  4. DB - Shared database layer (models, migrations)

Frontend (Next.js)

  • Blockchain explorer UI
  • Direct RPC queries (via Polkadot.js)
  • Enhanced data from backend API

πŸš€ Quick Start

Using Docker Compose (Backend Only)

# 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 down

Backend services will be available at:

Then run the frontend separately:

cd frontend
npm install
npm run dev

Frontend will be available at http://localhost:3000

Manual Setup

Prerequisites

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 redis

Backend

cd 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 verifier

Frontend

cd frontend

# Install dependencies
npm install

# Copy environment
cp .env.example .env.local
# Edit .env.local

# Run development server
npm run dev

πŸ“¦ Backend Architecture

Services

backend/
β”œβ”€β”€ 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

SDK Integration

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...
}

Database Schema

PostgreSQL tables:

  • blocks - Indexed blocks
  • extrinsics - Transactions
  • events - Blockchain events
  • contracts - Deployed contracts
  • contract_verifications - Verification requests
  • accounts - Cached account balances

Migrations: backend/crates/db/migrations/

API Endpoints

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

🎨 Frontend Features

Core Explorer

  • πŸ” 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

Custom Pallets

  • πŸ“‹ Tasks - TaskRegistry pallet integration
  • πŸ–₯️ Providers - ProviderStaking pallet
  • πŸ† Leaderboard - TestnetPoints tracking
  • πŸ’° Rewards - RewardDistribution pallet

πŸ”§ Development

Backend

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 fmt

Frontend

cd frontend

# Development
npm run dev

# Build
npm run build
npm start

# Lint
npm run lint

🐳 Docker

Build Images

# Backend
docker build -t glinscan-backend ./backend

# Frontend
docker build -t glinscan-frontend ./frontend

Production Deployment

docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d

πŸ“Š Environment Variables

Backend (.env)

DATABASE_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-verifier

Frontend (.env.local)

NEXT_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=18

🚒 Deployment

Backend (Railway)

Deploy 3 services:

  1. Indexer service
  2. API service
  3. Verifier service

Plus PostgreSQL and Redis add-ons.

Frontend (Vercel)

cd frontend
vercel --prod

Or connect GitHub repo to Vercel dashboard.

πŸ“š Related Projects

🀝 Contributing

Contributions welcome! Please see CONTRIBUTING.md.

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing)
  5. Open Pull Request

πŸ“„ License

Apache 2.0 - see LICENSE for details.

πŸ”— Links

About

Production-grade blockchain explorer for the GLIN network. Built with Next.js 15, Polkadot.js, and hybrid architecture.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors