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 🙏

© 2025 – Pkg Stats / Ryan Hefner

snet-sdk-core

v0.1.8

Published

SingularityNET core SDK for JS

Downloads

60

Readme

snet-sdk-core

SingularityNET SDK core for JavaScript

Getting Started

This package provides the core functionality for interacting with the AI service daemon, handling connections, and managing payment strategies. It serves as the common foundation for both Node.js and Web JavaScript SDKs.

  • core – The main SDK functionality.
  • nodeJS – Node.js-specific implementations.
  • web – Web (browser) integrations.

Features

  • Daemon Connection Management: Establish and maintain connections with the AI service daemon
  • Payment Strategy Abstraction: Support for multiple payment methods with easy extensibility
  • Request/Response Handling: Standardized communication with AI services
  • Cross-Platform Compatibility: Works in both Node.js and browser environments
  • MetaMask Integration: Built-in support for Ethereum payments via MetaMask wallet

Installation

npm install snet-sdk-core

Architecture

Usage

Prerequisites

Before using the Core JS SDK, ensure:

  • Your wallet has sufficient ETH balance to cover transaction gas costs
  • Your wallet has enough AGIX or FET tokens to cover service execution costs

Required Implementations

For a complete solution, you'll need to implement:

| Component | Description | |-----------|-------------| |Service Client | Network communication handlers for your target environment | |Payment Strategies|Web/Node-specific versions of Free, Paid, and Prepaid strategies| |Wallet Adapter| Platform-specific wallet/account management| |Stubs| Generate and use stubs from .proto depending on the type of platform|

Payment Strategies

Overview

The SDK provides three payment strategies:

Paid Pay-per-call model where each service call is individually charged

Prepaid Fund a prepaid balance that gets consumed with each service call. Ideal for:

  • Concurrent service calls
  • Batch processing
  • High-frequency usage scenarios

Free Call Use available free call allowances (if applicable to your account).

Default (Recommended) The smart strategy that automatically:

  • Uses free calls when available
  • Falls back to paid strategy when free calls are exhausted

Since the Core JS SDK serves as the foundation for both Web and Node.js SDKs To implement a complete solution, you'll need to:

  • Extend payment strategy classes
  • Implement service clients
  • Define method descriptors

Best Practices

Error Handling: Implement consistent error handling across all strategies a Testing: Verify each payment strategy works in your target environment

Type Safety: Use TypeScript interfaces for method descriptors

Development

Working on the Core Package

If you're making changes to the core package, you should test its compatibility with both the web and nodeJS packages. Here's how:

  1. Set Up the Workspace

Place all three packages (core, nodeJS, and web) in the same parent folder. Example structure:

/workspace/
  ├── snet-sdk-core/
  ├── snet-sdk-nodejs/
  └── snet-sdk-web/
  1. Build the Core Package

Navigate to the core package and run:

cd snet-sdk-core
npm run build

This generates the compiled output in snet-sdk-core/dist.

  1. Link the Local Core Package

In the nodeJS and web packages, replace the snet-sdk-core dependency with a local file reference.

Update their respective package.json files to:

"snet-sdk-core": "file:../snet-sdk-core/dist"

Then, reinstall dependencies in each package:

npm install

Now, changes in the core package will reflect in the dependent packages during development and you can check all functionality using examples of web and nodeJS SDKs.

Handling Signature / Binary

The grpc API metadata is a map of key, value pair to store the headers.
The value can be either String or Buffer.

All binary headers should have -bin suffix in their names. Vice versa. A String header's name must not end with this.

NodeSDK and WebSDK use grpc and @improbable-eng/grpc-web respectively to make grpc API calls.