Skip to content

Substreams Module Development SDK (for developing Substreams JavaScript module)

License

Notifications You must be signed in to change notification settings

streamingfast/substreams-js-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@substreams/sdk

CI License: MIT

Substreams SDK for writing Substreams modules in TypeScript/JavaScript, suitable for running in the v8-powered JavaScript runtime inside Substreams.

This package provides decorators, handler registration, store abstraction, and runtime helpers to make writing Substreams modules in JS feel natural and type-safe.

This is not for consuming Substreams outputs like @substreams/core — this is for authoring Substreams modules in JS.


Quick Start

1. Install the SDK

# with pnpm
pnpm add @substreams/sdk

# or npm
npm install @substreams/sdk
  1. Write your Substreams module
import { substreams, Store } from "@substreams/sdk";
import { Events, EventsSchema } from "./pb/proto/contract_pb";

export default class Substreams {
	@substreams.handlers.map([EventsSchema], EventsSchema)
	map_events(input: Events): Events {
		// Transform logic here
		return input;
	}

	@substreams.handlers.store(EventsSchema)
	store_events(store: Store<Events>, input: Events) {
		for (const event of input.usdtTransfers) {
			store.set(event.evtIndex, event.evtTxHash, event);
		}
	}
}

About

Substreams Module Development SDK (for developing Substreams JavaScript module)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •