openSVM/zindexer
solana indexer for clickhouse in zig
refsZIndexer is a high-performance indexer for Solana Virtual Machine (SVM) networks, capable of subscribing to and indexing data from multiple networks simultaneously.
zig build
The indexer uses two configuration files:
src/rpc_nodes.json: HTTP RPC endpoints for each networksrc/ws_nodes.json: WebSocket endpoints for each networkYou can customize these files to add or remove networks, or to use different RPC providers.
# Run in real-time mode (default)
./zig-out/bin/zindexer
# Run in historical mode
./zig-out/bin/zindexer --mode historical
# Customize ClickHouse connection
./zig-out/bin/zindexer --database-type clickhouse --database-url localhost:9000 --database-user default --database-password "" --database-name solana
# Use QuestDB instead
./zig-out/bin/zindexer --database-type questdb --database-url localhost:9000 --database-user admin --database-password "quest" --database-name solana
# Show help
./zig-out/bin/zindexer --help
-m, --mode <mode>: Indexer mode (historical or realtime)-r, --rpc-nodes <file>: RPC nodes configuration file-w, --ws-nodes <file>: WebSocket nodes configuration file-t, --database-type <type>: Database type (clickhouse or questdb)-c, --database-url <url>: Database server URL-u, --database-user <user>: Database username-p, --database-password <pass>: Database password-d, --database-name <db>: Database name-b, --batch-size <size>: Batch size for historical indexing--max-retries <count>: Maximum retry attempts--retry-delay <ms>: Delay between retries in milliseconds--clickhouse-url <url>: ClickHouse server URL--clickhouse-user <user>: ClickHouse username--clickhouse-password <pass>: ClickHouse password--clickhouse-database <db>: ClickHouse database name--questdb-url <url>: QuestDB server URL--questdb-user <user>: QuestDB username--questdb-password <pass>: QuestDB password--questdb-database <db>: QuestDB database name-h, --help: Show help messageThe schema can be automatically applied to your database instance using the included script:
DB_TYPE=clickhouse CLICKHOUSE_URL="http://localhost:8123" ./scripts/apply_schema.sh
DB_TYPE=questdb QUESTDB_URL="http://localhost:9000" ./scripts/apply_schema.sh
ZIndexer is built with a modular architecture:
ZIndexer creates several tables in ClickHouse:
transactions: Basic transaction datainstructions: Instruction data with program IDsaccounts: Account state changesaccount_activity: Account usage statisticstoken_transfers: Token transfer eventstoken_accounts: Token account balancestoken_holders: Token holder informationnft_mints: NFT mint eventsnft_sales: NFT sale eventspool_swaps: AMM swap eventsliquidity_pools: AMM pool informationZIndexer uses GitHub Actions for CI/CD:
zig fmtStatus badges: