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

@windingtree/sdk-node

v1.3.9

Published

The WindingTree market protocol node

Downloads

57

Readme

@windingtree/sdk-node

This package provides a complete and customizable Winding Tree node, suitable for suppliers. It offers functionalities for managing offers and requests, as well as built-in connection and reconnection logic to the marketplace server. The Node class provides an easy way to handle all interactions with the Winding Tree marketplace.

Installation

pnpm i @windingtree/sdk-node

Key Concepts

  • Node: A Node represents a supplier in the Winding Tree network. It is capable of sending offers and handling requests.
  • Libp2p: Libp2p is a modular network stack that allows you to build your own peer-to-peer applications. The Node uses it for all network communications.
  • Peer-to-Peer Communication: Offers and requests are transmitted using a peer-to-peer (P2P) network, meaning they're sent directly between nodes.
  • Signer: The signer is responsible for signing offers with an Ethereum account to ensure the authenticity of the offer.

Usage

Below is an example of how to instantiate and use a Node:

import { createNode, NodeEvents } from '@windingtree/sdk-node';
import { OfferData } from '@windingtree/sdk-types';
import { polygonZkEvmTestnet } from 'viem/chains';

const node = createNode({
  topics: ['myTopic'],
  supplierId: 'mySupplierId',
  signerSeedPhrase: 'mySeedPhrase',
  chain: polygonZkEvmTestnet,
  contracts: { ...contractsConfig },
  serverAddress:
    '/ip4/127.0.0.1/tcp/33333/ws/p2p/QmcXbDrzUU5ERqRaronWmAJXwe6c7AEkS7qdcsjgEuWPCf', // Change to your server address
});

node.addEventListener<NodeEvents['connected']>('connected', () => {
  console.log('Node is connected.');
});

node.addEventListener<NodeEvents['message']>('message', ({ detail }) => {
  console.log('Received message:', detail);
});

await node.start();

API

  • createNode(options: NodeOptions): Creates a new Node instance. Options should include the server address, supplierId, topics, and the signer account details.
  • Node.start(): Starts the Node instance.
  • Node.stop(): Stops the Node instance.
  • Node.connected: Boolean property that indicates whether the Node is connected.
  • Node.makeOffer(offerOptions): Creates, signs, and publishes an offer. Returns the offer.
  • Node.handleRequest(event): Handles a request event.
  • Node.enable(): Enables the Node instance, allowing it to start listening to configured topics.
  • Node.disable(): Disables the Node instance, causing it to stop listening to all configured topics.

The Node class also emits several events, including 'start', 'stop', 'connected', 'disconnected', 'heartbeat', and 'message'. You can add event listeners for these events to react to changes in the Node's state.

Documentation

For full documentation and examples, visit windingtree.github.io/sdk

Contributing

Contribution guidelines

Testing

pnpm test