A real-time CKB blockchain data service providing WebSocket events and REST APIs for blockchain visualization.
- Real-time Data Streaming: WebSocket-based real-time blockchain events
- Comprehensive REST API: Full access to blocks, transactions, and chain state
- Chain Synchronization: Automatic synchronization with CKB network
- Database Storage: Persistent storage of blockchain data with Prisma ORM
- Event-driven Architecture: Decoupled event system for real-time updates
- Multi-network Support: Configurable for mainnet/testnet environments
This service acts as a generic, decoupled backend that:
- Connects to CKB network via RPC/WebSocket
- Synchronizes and stores blockchain data in SQLite database
- Provides real-time event streaming via WebSocket
- Exposes REST APIs for current state queries
- Supports any frontend visualization implementation
- Framework: NestJS
- Language: TypeScript
- Database: SQLite with Prisma ORM
- Real-time: Socket.IO for WebSocket connections
- Blockchain: CKB Lumos SDK
- Validation: Joi for configuration validation
- Package Manager: pnpm
- Node.js 18+
- pnpm (recommended) or npm
- CKB node access (testnet/mainnet)
-
Clone the repository
git clone <repository-url> cd ckb-chainviz
-
Install dependencies
pnpm install
-
Set up environment variables Create a
.envfile in the root directory:# Database DATABASE_URL="file:./database.db" # CKB Network Configuration CKB_NETWORK_TYPE="testnet" # or "mainnet" CKB_HTTP_RPC_URL="https://testnet.ckb.dev/" CKB_WS_RPC_URL="wss://testnet.ckb.dev/ws" # Optional: Server Configuration PORT=3000
-
Initialize the database
pnpm prisma generate pnpm prisma db push
pnpm run start:devpnpm run build
pnpm run start:prodpnpm run start:debug