RAILGUN Reloaded
    Preparing search index...

    Module @railgun-reloaded/scanner

    Source: dev b733b3c

    This module is currently under active development and not ready for production use. Please do not use this module until a stable release is published.

    @railgun-reloaded/scanner

    Unified blockchain data abstraction layer for RAILGUN events

    The scanner module provides a pluggable data source interface for fetching and processing RAILGUN events from multiple backends. It abstracts away the complexity of different data providers (Subsquid indexers, IPFS snapshots, RPC nodes) behind a unified async iterator API.

    • Multi-source support: Subsquid, Snapshot (IPFS), and RPC providers
    • Unified interface: Same API across all data sources via DataSource<T>
    • Streaming data: Memory-efficient async generators for large datasets
    • Type-safe events: Strongly typed RAILGUN events (Shield, Unshield, Transact)
    • Configurable chunking: Control batch sizes for optimal performance
    • Live sync support: Real-time event streaming (RPC provider only)
    npm install @railgun-reloaded/scanner
    

    Fast, indexed historical data from Subsquid GraphQL endpoints. It reads evmBlocksConnection. Of the hosted squids, only the Sepolia squid serves it; the mainnet squids serve the entity schema only. For another chain, pass customSubsquidUrl of an endpoint that serves the block layer.

    import { SubsquidProvider } from '@railgun-reloaded/scanner'

    const provider = new SubsquidProvider({ network: 'ethereumSepolia' })

    // A custom deployment can supply its endpoint explicitly instead:
    const customProvider = new SubsquidProvider({
    customSubsquidUrl: 'https://squid.subsquid.io/railgun-eth/graphql'
    })

    const iterator = provider.from({
    startHeight: 10000000n,
    endHeight: 15001000n,
    chunkSize: 100n,
    liveSync: false // Subsquid does not support live sync
    })

    for await (const block of iterator) {
    console.log(`Block ${block.number}: ${block.transactions.length} transactions`)
    for (const tx of block.transactions) {
    for (const actions of tx.actions) {
    // Process Shield, Unshield, Transact events
    }
    }
    }

    Provider guarantees, current readiness, composition semantics, and known canonicalization gaps are documented in src/sources/README.md.

    All providers implement the DataSource<T> interface:

    interface DataSource<T extends EVMBlock> {
    isLiveProvider: boolean
    head(): Promise<bigint>
    from(options: SyncOptions): AsyncGenerator<T>
    destroy(): void
    }
    type SyncOptions = {
    startHeight: bigint // Starting block number
    endHeight?: bigint // Ending block number (optional)
    chunkSize: bigint // Number of blocks per request
    liveSync?: boolean // Enable real-time streaming (RPC only)
    }

    The scanner normalizes all events into typed structures:

    type EVMBlock = {
    number: bigint
    hash: Uint8Array
    timestamp: bigint
    transactions: EVMTransaction[]
    }

    type EVMTransaction = {
    hash: Uint8Array
    index: number
    from: Uint8Array
    actions: Action[][] // Nested array of Shield/Unshield/Transact events
    }

    type Action = Shield | Unshield | Transact

    enum ActionType {
    Unshield = 'Unshield',
    GeneratedCommitment = 'GeneratedCommitment',
    ShieldCommitment = 'ShieldCommitment',
    EncryptedCommitment = 'EncryptedCommitment',
    TransactCommitment = 'TransactCommitment'
    }
    npm run build
    
    npm test
    

    MIT

    CustomGQLProvider
    RPCConnectionManager
    RPCProvider
    SnapshotProvider
    SourceAggregator
    SubsquidProvider
    ActionType
    RailgunTxidVersion
    extractRailgunTransactions
    Token
    CommitmentPreimage
    GeneratedCommitment
    ShieldCommitment
    Shield
    Unshield
    Ciphertext
    EncryptedCommitment
    TransactCommitment
    Transact
    Action
    EVMTransaction
    EVMBlock
    ScannedRailgunTransactionUnshield
    ScannedRailgunTransaction
    CustomGQLProviderConfig
    SyncOptions
    DataSource
    FetchLike
    SnapshotDecoder
    SnapshotProviderConfig
    SubsquidProviderConfig