Skip to main content
Example code snippets to stream from the indexer for auction module related data using StreamManagerV2.

Using gRPC Stream with StreamManagerV2

Stream auction bids

import { getNetworkEndpoints, Network } from '@injectivelabs/networks'
import { 
  StreamManagerV2,
  IndexerGrpcAuctionStreamV2 
} from '@injectivelabs/sdk-ts/client/indexer'

const endpoints = getNetworkEndpoints(Network.Testnet)
const stream = new IndexerGrpcAuctionStreamV2(endpoints.indexer)

const streamManager = new StreamManagerV2({
  id: 'auction-bids',
  streamFactory: () => stream.streamBids({
    callback: (response) => {
      streamManager.emit('data', response)
    }
  }),
  onData: (bids) => {
    console.log(bids)
  },
  retryConfig: { enabled: true }
})

streamManager.on('connect', () => console.log('Stream connected'))
streamManager.start()