IndexerClient

interface IndexerClient

Client for the Midnight indexer GraphQL API.

Provides access to ledger events, blocks, and network state for light wallet implementation.

Light Wallet Architecture:

  • Subscribe to transaction events via WebSocket

  • Track UTXOs locally

  • Calculate balances from UTXO set

  • No full node required

GraphQL Endpoints (composed from NetworkConfig.forNetwork(...).indexerBaseUrl):

  • HTTP Queries: {baseUrl}/graphql

  • WebSocket Subscriptions: {baseUrl}/graphql/ws (scheme switched to ws(s)://)

See also

for implementation details

for the canonical URL source

Inheritors

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun close()

Close the client and release resources.

Link copied to clipboard
abstract suspend fun getCurrentBlockWithParams(): BlockInfo

Get current block with ledger parameters.

Link copied to clipboard
abstract suspend fun getEventsInRange(fromId: Long, toId: Long): List<RawLedgerEvent>

Get historical events in range.

Link copied to clipboard
abstract suspend fun getNetworkState(): NetworkState

Get current network synchronization state.

Link copied to clipboard
abstract suspend fun isHealthy(): Boolean

Check if indexer is healthy and reachable.

Link copied to clipboard
abstract suspend fun queryContractState(address: String): String

Query the current on-chain state of a deployed contract.

Link copied to clipboard
abstract suspend fun queryDustEvents(maxBlocks: Int = 100): String

Query all dust events via WebSocket subscription.

Link copied to clipboard
abstract suspend fun queryDustEventsDelta(fromId: Long, timeoutMs: Long = DELTA_TIMEOUT_MS): DustSyncResult

Query dust events starting from a specific event ID (delta sync).

Link copied to clipboard
abstract suspend fun queryZswapEvents(): String

Query all zswap (shielded) events from the blockchain via subscription.

Link copied to clipboard
abstract suspend fun resetConnection()

Reset the WebSocket connection (close all active subscriptions).

Link copied to clipboard
abstract fun subscribeToBlocks(): Flow<BlockInfo>

Subscribe to new blocks.

Link copied to clipboard
abstract fun subscribeToDustEvents(fromId: Long? = null): Flow<RawLedgerEvent>

Subscribe to dust ledger events via WebSocket.

Link copied to clipboard
abstract fun subscribeToUnshieldedTransactions(address: String, transactionId: Int? = null): Flow<UnshieldedTransactionUpdate>

Subscribe to unshielded transactions for an address.

Link copied to clipboard
abstract fun subscribeToZswapEvents(fromId: Long? = null): Flow<RawLedgerEvent>

Subscribe to zswap ledger events.