0.14.0 • Published 3 months ago

@substreams/react v0.14.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

SubstreamsJS

CI License: MIT

TypeScript library for consuming Substreams suitable for web browsers, Node.js and alternative runtimes.

import { createGrpcTransport } from "@connectrpc/connect-node";
import {
  createAuthInterceptor,
  createRegistry,
  createRequest,
  fetchSubstream,
  isEmptyMessage,
  streamBlocks,
  unpackMapOutput,
} from "@substreams/core";

const SUBSTREAM = "https://github.com/streamingfast/substreams-uniswap-v3/releases/download/v0.2.7/substreams.spkg";
const MODULE = "map_pools_created";

const substream = await fetchSubstream(SUBSTREAM);
const registry = createRegistry(substream);
const transport = createGrpcTransport({
  baseUrl: "https://mainnet.eth.streamingfast.io",
  httpVersion: "2",
  interceptors: [createAuthInterceptor("<YOUR TOKEN>")],
  jsonOptions: {
    typeRegistry: registry,
  },
});

const request = createRequest({
  substreamPackage: substream,
  outputModule: MODULE,
  productionMode: true,
  stopBlockNum: "+10000",
});

for await (const response of streamBlocks(transport, request)) {
  const output = unpackMapOutput(response.response, registry);
  if (output !== undefined && !isEmptyMessage(output)) {
    console.dir(output.toJson({ typeRegistry: registry }));
  }
}

Installation

Note This library is pure ESM and no longer provides CommonJS (CJS) exports. If your project uses CommonJS, you will have to convert to ESM or use the dynamic import() function. Please don't open issues for questions regarding CommonJS / ESM.

# Using pnpm
pnpm add @substreams/core

# Using yarn
yarn add @substreams/core

# Using npm
npm install @substreams/core

Packages

Authors

License

MIT License

0.14.0

3 months ago

0.13.0

3 months ago

0.13.1

3 months ago

0.12.0

3 months ago

0.11.0

4 months ago

0.10.0

4 months ago

0.9.0

5 months ago

0.8.0

5 months ago

0.7.0

5 months ago

0.6.1

6 months ago

0.0.0-main-864c55a

6 months ago

0.6.0

6 months ago

0.0.0-main-4b20194

6 months ago

0.0.0-main-97118a2

6 months ago

0.5.2

7 months ago

0.5.0

7 months ago

0.4.1

7 months ago

0.4.0

7 months ago

0.3.0

7 months ago

0.2.0

8 months ago

0.1.11

10 months ago

0.1.10

10 months ago

0.1.9

10 months ago

0.1.8

10 months ago

0.1.7

11 months ago

0.1.6

11 months ago

0.1.5

11 months ago

0.1.4

12 months ago

0.1.3

12 months ago

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago