npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@stratumn/store-client

v0.1.6

Published

A client to interact with a Chainscript Store.

Readme

Chainscript Store Client

A store is a database abstraction specifically designed for working with Chainscript.

Stratumn provides multiple store implementations and anyone can build a new store that meets their performance/scalability requirements.

Some store implementations can be found here.

Usage: HTTP client

Create and find segments

The unit of data in Chainscript is a link. A link is immutable (making it a good fit for blockchains) and describes a simple step that takes place in a shared process.

Once a link is stored it can be addressed by its link hash. Authenticity of the link can be verified by re-hashing it and checking that the hash matches.

A link is then wrapped inside a segment that allows enriching it with mutable data such as proofs of existence (evidences).

import { LinkBuilder } from "@stratumn/js-chainscript";
import {
  Pagination,
  SegmentsFilter,
  StoreHttpClient
} from "@stratumn/store-client";

// This is a new link that your application wants to store.
// In this case it initializes a process for tracking the 2018 election.
const link = new LinkBuilder("voting protocol", "2018 election")
  .withStep("init")
  .build();

// This is the url where the store you want to use is hosted.
const storeEndpoint = "https://store.your-domain.com";

const client = new StoreHttpClient(storeEndpoint);
await client.createLink(link);

// The link can be addressed by its hash.
// The link is wrapped in a segment that enriches it with mutable metadata.
const segment = await client.getSegment(link.hash());

// Or you can search for segments using filtering options.
const filters = new SegmentsFilter("voting protocol")
  .withStep("init")
  .withoutParent();
// And provide pagination options (skip 5 elements and return 10 elements).
const pageOptions = new Pagination(5, 10);
const segments = await client.findSegments(filters, pageOptions);

List maps

A process can have multiple instances, that we call maps. A map is identified by its map ID.

You can easily list all the maps of a given process to then drill into a specific instance.

import { LinkBuilder } from "@stratumn/js-chainscript";
import { StoreHttpClient } from "@stratumn/store-client";

const vote1 = new LinkBuilder("vote_tracker", "2018_Q1").build();
const vote2 = new LinkBuilder("vote_tracker", "2018_Q2").build();
const other = new LinkBuilder("home_automation", "fridge").build();

const client = new StoreHttpClient("https://store.stratumn.com");
await client.createLink(vote1);
await client.createLink(vote2);
await client.createLink(other);

// Will contain ["2018_Q1", "2018_Q2"]
const mapIDs = await client.getMapIDs("vote_tracker");

Adding evidence

Once a link has been stored, it is recommended to produce some external evidence of its existence.

A fossilizer can be used to achieve that and then store the new evidence in the Chainscript store.

import { Evidence, LinkBuilder } from "@stratumn/js-chainscript";
import {
  FossilizedEvent,
  FossilizerHttpClient
} from "@stratumn/fossilizer-client";
import { StoreHttpClient } from "@stratumn/store-client";

const store = new StoreHttpClient("https://store.stratumn.com");
const link = new LinkBuilder("car_insurance", "user42").build();
await store.createLink(link);

const fossilizer = new FossilizerHttpClient(
  "https://fossilize.stratumn.com",
  async (e: FossilizedEvent) => {
    // Store each new evidence.
    // We know that in our application e.data will always be a link hash.
    await store.addEvidence(e.data, e.evidence);
  }
);

// Fossilizing the link will provide an asynchronous evidence.
await fossilizer.fossilize(
  Buffer.from(link.hash()).toString("hex"),
  "user42's car insurance audit trail"
);

Subscribe to notifications

Chainscript stores send notifications about important events to connected clients.

It's likely that your application will have multiple clients producing links connected to the same store. Subscribing to notifications lets you know when other participants create links or add evidence.

import {
  SAVED_EVIDENCES_EVENT,
  SAVED_LINKS_EVENT,
  StoreEvent,
  StoreHttpClient
} from "@stratumn/store-client";

const store = new StoreHttpClient(
  "https://store.stratumn.com",
  (e: StoreEvent) => {
    if (e.type === SAVED_LINKS_EVENT) {
      const newLinks = e.links;
      // Do something with the links (display a notification or update UI).
    }

    if (e.type === SAVED_EVIDENCES_EVENT) {
      e.evidences.map(ev => {
        if (ev.linkHash === "some important link we're watching") {
          // Trigger something appropriate.
        }
      });
    }
  }
);

Provide a custom logger

The http client accepts an optional logger argument. If you are interested in logging the events raised by this package, here is how you can do it:

import { StoreEvent, StoreHttpClient } from "@stratumn/store-client";

// Custom client that sends logging events to the console.
const client = new StoreHttpClient(
  "http://localhost:5000/",
  (e: StoreEvent) => {
    console.info(e);
  },
  {
    info(event: any) {
      console.info(event);
    },
    warn(event: any) {
      console.warn(event);
    },
    error(event: any) {
      console.error(event);
    }
  }
);