Skip to content

02StreamingIndexerAccount

Ivan Angelkoski edited this page Jun 12, 2023 · 4 revisions

Attention! The Docs have been moved to https://docs.ts.injective.network/

Example code snippets to stream from the indexer for subaccount related data.

Using gRPC stream

  • Stream a subaccount balance
import { IndexerGrpcAccountStream } from "@injectivelabs/sdk-ts";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";

const endpoints = getNetworkEndpoints(Network.TestnetK8s);
const indexerGrpcAccountStream = new IndexerGrpcAccountStream(
  endpoints.indexer
);

const subaccountId = "0x...";

const streamFn = indexerGrpcAccountStream.streamSubaccountBalance.bind(
  indexerGrpcAccountStream
);

const callback = (subaccountBalance) => {
  console.log(subaccountBalance);
};

const streamFnArgs = {
  subaccountId,
  callback,
};

streamFn(streamFnArgs);

⚠️ DOCUMENTATION ⚠️

Clone this wiki locally