Package Exports
- substreams
- substreams/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (substreams) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Substreams Javascript consumer
SubstreamJavascript consumer library using Node.js Event emitters.
Install
Using NPM:
npm install --save substreamsor using Yarn:
yarn add substreamsRequirements
Endpoints
Quickstart
const { Substreams, download } = require("substreams");
// User parameters
const url = "https://github.com/streamingfast/substreams-ethereum-quickstart/releases/download/1.0.0/substreams-ethereum-quickstart-v1.0.0.spkg";
const outputModule = "map_block";
const startBlockNum = "12292922";
const stopBlockNum = "+10";
(async () => {
// download Substream from IPFS
const spkg = await download(url);
// Initialize Substreams
const substreams = new Substreams(spkg, outputModule, {
startBlockNum,
stopBlockNum,
authorization: process.env.SUBSTREAMS_API_TOKEN
});
// first block received
substreams.on("start", (cursor, clock) => {
console.log({status: "start", cursor, clock});
});
// stream of decoded MapOutputs
substreams.on("anyMessage", (message) => {
console.log({message});
});
// end of stream
substreams.on("end", (cursor, clock) => {
console.log({status: "end", cursor, clock});
});
// start streaming Substream
substreams.start();
})();Tests
$ npm ci
$ npm test