-
Notifications
You must be signed in to change notification settings - Fork 196
02StreamingIndexerExplorer
Ivan Angelkoski edited this page Jun 12, 2023
·
4 revisions
⚠️ The Docs have been moved to https://docs.ts.injective.network/querying/querying-api/streaming/streaming-indexer-explorer
Example code snippets to stream from the indexer for explorer module related data.
- stream blocks
import { IndexerGrpcExplorerStream } from "@injectivelabs/sdk-ts";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";
const endpoints = getNetworkEndpoints(Network.TestnetK8s);
const indexerGrpcExplorerStream = new IndexerGrpcExplorerStream(
endpoints.indexer
);
const streamFn = indexerGrpcExplorerStream.blocks.bind(
indexerGrpcExplorerStream
);
const callback = (blocks) => {
console.log(blocks);
};
const streamFnArgs = {
callback,
};
streamFn(streamFnArgs);
- stream blocks with transactions
import { IndexerGrpcExplorerStream } from "@injectivelabs/sdk-ts";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";
const endpoints = getNetworkEndpoints(Network.TestnetK8s);
const indexerGrpcExplorerStream = new IndexerGrpcExplorerStream(
endpoints.indexer
);
const streamFn = indexerGrpcExplorerStream.blocksWithTxs.bind(
indexerGrpcExplorerStream
);
const callback = (blocksWithTransactions) => {
console.log(blocksWithTransactions);
};
const streamFnArgs = {
callback,
};
streamFn(streamFnArgs);
- stream transactions
import { IndexerGrpcExplorerStream } from "@injectivelabs/sdk-ts";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";
const endpoints = getNetworkEndpoints(Network.TestnetK8s);
const indexerGrpcExplorerStream = new IndexerGrpcExplorerStream(
endpoints.indexer
);
const streamFn = indexerGrpcExplorerStream.streamTransactions.bind(
indexerGrpcExplorerStream
);
const callback = (transactions) => {
console.log(transactions);
};
const streamFnArgs = {
callback,
};
streamFn(streamFnArgs);
Powering the future of decentralized finance.