# @substreams/core

> [![CI](https://github.com/substreams-js/substreams-js/actions/workflows/on-push-to-main.yaml/badge.svg)](https://github.com/substreams-js/substreams-js/actions/workflows/on-push-to-main.yaml) [![License: MIT](https://img.shields.io/github/license/substrea

Latest version **0.17.0** (published 2024-12-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @substreams/core
pnpm add @substreams/core
yarn add @substreams/core
bun add @substreams/core
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance.

Warnings: low downloads; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.17.0 |
| Published | 2024-12-16 |
| First published | 2023-05-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.8 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 22 |
| Maintainers | deniscarriere, abourget, thefubhy |

## Links

- npm: https://www.npmjs.com/package/@substreams/core
- Repository: https://github.com/substreams-js/substreams-js
- Homepage: https://github.com/substreams-js/substreams-js#readme
- Issues: https://github.com/substreams-js/substreams-js/issues
- npm.io page: https://npm.io/package/@substreams/core

## Recent versions

- 0.17.0 (latest) — 2024-12-16
- 0.0.0-main-fb1837c8c570391b1777a1ee49122d7a8fa46f36 (main) — 2024-07-26
- 0.16.0 — 2024-02-27
- 0.0.0-main-fc928414b3bc814eac0c19d475a15e2770b1690b — 2024-02-27
- 0.15.1 — 2024-02-09
- 0.0.0-main-204cfa0ac332e87fb715cbe87c84459f0a3cf955 — 2024-02-09
- 0.15.0 — 2024-02-09
- 0.14.0 — 2024-02-09
- 0.0.0-main-798710fff3467e6a8c9ddf3990e6fe5d1b2b01e9 — 2024-02-09
- 0.13.0 — 2024-02-02
- 0.0.0-main-72ff1a67bca6dcc269f2458733f6c153814dfa1f — 2024-02-02
- 0.0.0-main-3b6bf2efc3643beb8f1d1b24f9978003065f1925 — 2024-02-02
- 0.12.0 — 2024-01-16
- 0.0.0-main-891988f6eb00e7fd445a90b4b4dc74c5d0a070b2 — 2024-01-16
- 0.11.0 — 2024-01-05
- … 74 more at https://npm.io/package/@substreams/core/versions

## README

# SubstreamsJS

[![CI](https://github.com/substreams-js/substreams-js/actions/workflows/on-push-to-main.yaml/badge.svg)](https://github.com/substreams-js/substreams-js/actions/workflows/on-push-to-main.yaml)
[![License: MIT](https://img.shields.io/github/license/substreams-js/substreams-js)](/LICENSE)

TypeScript library for consuming [Substreams](https://substreams.streamingfast.io/) suitable for web browsers, Node.js and alternative runtimes.

```typescript
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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) and no longer provides CommonJS (CJS) exports. If your project uses CommonJS, you will have to [convert to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) or use the [dynamic `import()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) function. Please don't open issues for questions regarding CommonJS / ESM.

```bash
# Using pnpm
pnpm add @substreams/core

# Using yarn
yarn add @substreams/core

# Using npm
npm install @substreams/core
```

## Packages

- [@substreams/core](https://www.npmjs.com/package/@substreams/core):
  Provides all core functionality for interacting with substreams packages and consuming substream modules. ([source code](packages/core)).
- [@substreams/manifest](https://www.npmjs.com/package/@substreams/manifest):
  Parses and validates `substreams.yaml` manifests and bundles them into substream packages. ([source code](packages/manifest)).
- [@substreams/mermaid](https://www.npmjs.com/package/@substreams/mermaid):
  Generates mermaid graph visualizations of substream module graphs. ([source code](packages/mermaid)).
- [@substreams/react](https://www.npmjs.com/package/@substreams/react):
  Lightweight utilities for building React based user interfaces on top of substreams. ([source code](packages/react)).

## Authors

- [@fubhy](https://github.com/fubhy) (fubhy.eth, [Twitter](https://twitter.com/thefubhy))

## License

[MIT](/LICENSE) License

---
_Source: https://npm.io/package/@substreams/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
