npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@solixdb/core

v1.0.0

Published

Core indexing engine for SolixDB

Readme

@solixdb/core

Production-grade Solana blockchain indexer core engine.

Features

Multiple Indexing Modes

  • Polling Mode: Fetch historical blocks via RPC
  • Streaming Mode: Real-time updates via WebSocket
  • Hybrid Mode: Historical + live data (coming soon)

High Performance

  • Adaptive batch sizing
  • Concurrent block processing
  • Efficient buffering and batching

Flexible Querying

  • Fluent query builder API
  • Filter by slot, time, program, account
  • Pagination and streaming support

Production Ready

  • Comprehensive error handling
  • Automatic retry with exponential backoff
  • Health checks and monitoring
  • Detailed logging

Installation

pnpm add @solixdb/core

Quick Start

import { SolanaIndexer } from "@solixdb/core";
import { JSONStorage } from "@solixdb/storage-adapters";
import { DefaultProvider } from "@solixdb/rpc-providers";

// 1. Create storage adapter
const storage = new JSONStorage({
  directory: "./data",
});

// 2. Create RPC provider
const rpc = new DefaultProvider({
  endpoint: "https://api.mainnet-beta.solana.com",
});

// 3. Create and configure indexer
const indexer = new SolanaIndexer(
  {
    mode: "polling",
    startSlot: 100000,
    endSlot: 100100,
    batchSize: 10,
    commitment: "confirmed",
  },
  storage,
  rpc
);

// 4. Start indexing
await indexer.start();

// 5. Query indexed data
const blocks = await indexer.query.getRecentBlocks(10);
console.log("Recent blocks:", blocks);

// 6. Stop when done
await indexer.stop();

Configuration

interface IndexerConfig {
  // Indexing mode
  mode: "polling" | "streaming" | "hybrid";

  // Slot range (optional)
  startSlot?: number;
  endSlot?: number;

  // Performance tuning
  batchSize?: number; // Default: 10
  pollingInterval?: number; // Default: 1000ms
  commitment?: "processed" | "confirmed" | "finalized";

  // Retry configuration
  maxRetries?: number; // Default: 3
  retryDelay?: number; // Default: 1000ms

  // Filtering
  programIds?: string[]; // Only index these programs
  accountFilters?: AccountFilter[]; // Custom account filters

  // Logging
  logLevel?: "debug" | "info" | "warn" | "error";
}

Usage Examples

Historical Indexing

Index a specific range of slots:

const indexer = SolanaIndexer.forHistoricalData(
  100000, // start slot
  200000, // end slot
  storage,
  rpc,
  {
    batchSize: 20,
    logLevel: "info",
  }
);

await indexer.start();

// Wait for completion
await indexer.waitForCompletion();

Live Indexing

Stream real-time blockchain data:

const indexer = SolanaIndexer.forLiveData(storage, rpc, {
  mode: "streaming",
  logLevel: "info",
});

await indexer.start();

// Runs continuously, call stop() when done

Program-Specific Indexing

Index only specific programs:

const indexer = new SolanaIndexer(
  {
    mode: "polling",
    startSlot: 100000,
    programIds: [
      "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", // SPL Token
      "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4", // Jupiter
    ],
  },
  storage,
  rpc
);

await indexer.start();

Resume from Last Indexed Slot

Automatically resume from where you left off:

const indexer = SolanaIndexer.fromLatest(storage, rpc);

// Starts from the last indexed slot in storage
await indexer.start();

Querying Data

Using Query Builder

import { QueryBuilder } from "@solixdb/core";

// Get recent blocks
const query = QueryBuilder.create().orderBySlot("desc").limit(10).build();

const result = await indexer.query.queryBlocks(query);

Quick Queries

// Recent blocks
const blocks = await indexer.query.getRecentBlocks(10);

// Blocks in range
const rangeBlocks = await indexer.query.getBlocksInRange(100, 200);

// Transactions for a program
const txs = await indexer.query.getTransactionsForProgram(
  "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
);

// Transactions for an account
const accountTxs = await indexer.query.getTransactionsForAccount(
  "YourAccountPublicKey"
);

// Single transaction
const tx = await indexer.query.getTransaction("signature...");

// Single block
const block = await indexer.query.getBlock(123456);

Streaming Large Result Sets

// Stream blocks (for large datasets)
for await (const block of indexer.query.streamBlocks(query)) {
  console.log("Block:", block.slot);
  // Process block...
}

// Stream transactions
for await (const tx of indexer.query.streamTransactions(query)) {
  console.log("Transaction:", tx.signature);
  // Process transaction...
}

Monitoring

Get Statistics

const stats = indexer.getStats();
console.log({
  status: stats.status,
  currentSlot: stats.currentSlot,
  processedBlocks: stats.processedBlocks,
  processedTransactions: stats.processedTransactions,
  blocksPerSecond: stats.blocksPerSecond,
  transactionsPerSecond: stats.transactionsPerSecond,
});

Progress Tracking (Historical Mode)

setInterval(() => {
  const progress = indexer.getProgress();
  if (progress !== null) {
    console.log(`Progress: ${progress.toFixed(2)}%`);
  }
}, 5000);

Health Checks

const isHealthy = await indexer.healthCheck();
if (!isHealthy) {
  console.error("Indexer health check failed!");
}

Advanced Usage

Custom Processing

import { BlockProcessor } from "@solixdb/core";

const processor = new BlockProcessor({
  includeTransactions: true,
  includeInstructions: true,
  includeAccounts: false,
  programFilters: ["YourProgramId"],
});

processor.configure({
  includeRewards: true,
});

Custom Retry Logic

import { retry } from "@solixdb/core";

const data = await retry(
  async () => {
    // Your async operation
    return await fetchSomeData();
  },
  {
    maxRetries: 5,
    initialDelay: 2000,
    maxDelay: 30000,
    backoffMultiplier: 2,
  },
  "fetchSomeData"
);

Custom Logging

import { createLogger } from "@solixdb/core";

const logger = createLogger({
  level: "debug",
  prefix: "MyIndexer",
  enableTimestamp: true,
  enableColors: true,
});

logger.info("Indexer started");
logger.debug("Processing block", { slot: 12345 });
logger.error("Error occurred", error);

Architecture

SolanaIndexer
├── IndexerEngine (orchestrates everything)
│   ├── IndexerState (tracks progress)
│   ├── IndexerConfig (configuration)
│   ├── BlockProcessor (processes blocks)
│   │   ├── TransactionProcessor
│   │   └── AccountProcessor
│   ├── RPCPoller (polling mode)
│   │   └── PollingStrategy
│   └── StreamManager (streaming mode)
│       ├── WebSocketStream
│       └── StreamBuffer
├── Storage Adapter (persists data)
└── RPC Provider (fetches data)

Error Handling

import { IndexerError, RPCError, StorageError } from "@solixdb/core";

try {
  await indexer.start();
} catch (error) {
  if (error instanceof IndexerError) {
    console.error("Indexer error:", error.message, error.code);
  } else if (error instanceof RPCError) {
    console.error("RPC error:", error.message);
  } else if (error instanceof StorageError) {
    console.error("Storage error:", error.message);
  }
}

Performance Tips

  1. Batch Size: Larger batches = higher throughput, but more memory usage
  2. Commitment Level: Use 'confirmed' for a balance of speed and finality
  3. Program Filters: Filter early to reduce processing overhead
  4. Adaptive Polling: Enable for automatic performance tuning
  5. Storage Choice: Use PostgreSQL/ClickHouse for production workloads

License

MIT

Support

  • Documentation: https://docs.solixdb.xyz
  • GitHub Issues: https://github.com/SolixDB/solixdb/issues