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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@subspace/subspace

v0.2.0

Published

This JavaScript library provides a simple API to submit and retrieve user data to the Subspace network.

Downloads

3

Readme

@subspace/subspace

This JavaScript library provides a simple API to submit and retrieve user data to the Subspace network. The project is in active development with a live test network designed to provide scalable and distributed archival storage.

Storage API.

The Storage API exposes a Subspace node feature called pallet-object-store that implements RPC methods to store an Object from user-provided data. The user can send a simple text or even a file; the pallet-object-store receives an Object to store and generate an objectId.

  • put: Receive a signed transaction containing an Object to store. It emit a DataSubmitted Event with an objectId to get the Object from the network.

  • findObject: Receives an objectId to find the related Object stored, if it exists this method will return the Object data.

To expose these methods, this library implements two main classes:

  • Identity: Class to load a keyPair from different sources. An instance of this class is required to create a SubspaceClient.

    • fromWeb3: Load keyPair from web3Accounts using @polkadot/extension-dapp.

    • fromUri: Load keyPair from a secret URI, Example: //Alice///password or a mnemonic phrase.

  • SubspaceClient: Class that loads an Identity instance and creates providers to interact with the network.

    • connect: Create an ApiPromise and WsProvider, returning a SubspaceClient instance ready to call:

      • putObject: Receives an Object as Uint8Array, it create and submit a signed put transaction and return an objectId.

      • getObject: Receives an objectId calling findObject to return the Object as Uint8Array.

Run this project.

Clone this repository:

  • git clone https://github.com/subspace/subspace.js.git

Install dependencies

  • npm ci

Build the library.

  • npm run build

Usage

// Import the library.
import { SubspaceClient, Identity } from "@subspace/subspace";

// Generate an Identity from node.js
const identity = await Identity.fromUri(mnemonic);
// Generate an Identity from broser using web3Account (injected by extension)
const identity = await Identity.fromWeb3();

// Generate a SubspaceClient and connect to node and farmer rpc endpoints.
const subspaceClient = await SubspaceClient.connect(
  identity,
  NODE_WS_PROVIDER,
  FARMER_WS_PROVIDER
);

// Put the file as (Uint8Array) in to the objectStore and return the objectId
const objectId: string = await subspaceClient.putObject(objectData);

// Using the objectId get the file as (Uint8Array) from the objectStore.
const object: Uint8Array = await subspaceClient.getObject(objectId);

Run the examples.

Running a local network

You can check the Subspace repository to learn how configure and run your local network.