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

openledger-datanet-sdk

v0.0.1

Published

SDK for OpenLedger Datanet integration

Readme

OpenLedger Datanet SDK

SDK for OpenLedger Datanet integration that allows you to add data points to the blockchain and publish metadata to an API endpoint.

Installation

npm install openledger-datanet-sdk

Usage

Basic Usage

import { OpenLedgerDatanetSDK } from 'openledger-datanet-sdk';

const sdk = new OpenLedgerDatanetSDK({
  datanetId: 'your-datanet-uuid', // uuid
  datanetAddress: 'your-datanet-address',
  privateKey: 'your-private-key',
  rpcUrl: 'your-rpc-url',
  apiUrl: 'your-api-url',
  url: 'your-openledger-url',
  authToken: 'your-auth-token'
});

// Add data points
const result = await sdk.addDataPoints([
  { 
    chaindata: {
      datapointId: 1,
      userAddress: '0x...',
      datahash: 'your-data-hash'
    },
    metadata: {
      description: 'Your metadata',
      timestamp: Date.now()
    }
  }
], 'your-transaction-signature'); // signature is required

SIWE (Sign-In with Ethereum) Authentication

// SIWE with optional API integration
const loginResult = await OpenLedgerDatanetSDK.login({
  address: '0x...',
  domain: 'example.com',
  uri: 'https://example.com/login',
  chainId: 1,
  statement: 'Sign in to OpenLedger Datanet',
  privateKey: 'your-private-key',
  
  // Optional user profile data
  email: '[email protected]',
  name: 'John Doe',
  profileImage: 'https://example.com/avatar.jpg',
  referralCode: 'REF123',
  oplCode: 'OPL456',
  
  // Optional API integration
  apiUrl: 'https://api.openledger-datanet.com' // Makes POST /auth/login
});

// loginResult contains:
// {
//   message: "SIWE formatted message",
//   public_key: "0x...",
//   signature: "0x...",
//   email: "[email protected]",
//   name: "John Doe",
//   image_url: "https://example.com/avatar.jpg",
//   referral_code: "REF123",
//   opl: "OPL456",
//   apiResponse: { /* API response data */ }
// }

// The SDK automatically sends this data to POST /auth/login:
// {
//   "message": "SIWE message...",
//   "public_key": "0x...",
//   "email": "[email protected]",
//   "name": "John Doe",
//   "image_url": "https://example.com/avatar.jpg",
//   "signature": "0x...",
//   "referral_code": "REF123",
//   "opl": "OPL456"
// }

// Verify the signature
const verificationResult = await OpenLedgerDatanetSDK.verifyLogin(
  loginResult.message,
  loginResult.signature
);

if (verificationResult.isValid) {
  console.log('User authenticated:', verificationResult.address);
}

API

Constructor

new OpenLedgerDatanetSDK(config: OpenLedgerDatanetSDKConfig)

Parameters:

  • datanetId (string): UUID of the datanet
  • datanetAddress (string): Address of the datanet contract
  • privateKey (string): Private key for blockchain transactions
  • rpcUrl (string): RPC URL for blockchain connection
  • apiUrl (string): API URL for metadata publishing
  • url (string): OpenLedgerSDK URL
  • authToken (string): Authentication token

Methods

addDataPoints(dataPoints, signature, gasOptions?)

Adds data points to the blockchain and publishes metadata to the API.

Parameters:

  • dataPoints (DataPoint[]): Array of data points to add
  • signature (string, required): Transaction signature
  • gasOptions (GasOptions, optional): Gas configuration options

Returns:

  • Promise that resolves to an object containing:
    • blockchainResult: Result from blockchain transaction
    • metadataResults: Array of results from metadata API calls

OpenLedgerDatanetSDK.login(params) (Static)

Creates and signs a SIWE (Sign-In with Ethereum) message for user authentication with optional API integration.

Parameters:

  • params (SiweLoginParams): Configuration for SIWE message
    • address (string): User's Ethereum address
    • domain (string): Domain requesting authentication
    • uri (string): URI of the login endpoint
    • chainId (number): Ethereum chain ID
    • privateKey (string): Private key to sign the message
    • nonce (string, optional): Custom nonce
    • statement (string, optional): Custom statement
    • apiUrl (string, optional): API base URL for login endpoint
    • email (string, optional): User's email
    • name (string, optional): User's display name
    • profileImage (string, optional): User's profile image URL
    • referralCode (string, optional): Referral code
    • oplCode (string, optional): OPL code

Returns:

  • Promise that resolves to SiweLoginResult containing the signed message, user data, and optional API response

API Integration:

  • When apiUrl is provided, automatically sends POST request to {apiUrl}/auth/login
  • Includes all user data and signature in the request body
  • Handles API errors gracefully without breaking the login flow

OpenLedgerDatanetSDK.verifyLogin(message, signature) (Static)

Verifies a SIWE signature.

Parameters:

  • message (string): The SIWE message that was signed
  • signature (string): The signature from the user's wallet

Returns:

  • Promise that resolves to SiweLoginResult with verification results

Types

DataPoint

interface DataPoint {
  chaindata: {
    datapointId: number;
    userAddress: string;
    datahash: string;
  };
  metadata: Record<string, any>;
}

SiweLoginParams

interface SiweLoginParams {
  address: string;
  domain: string;
  uri: string;
  chainId: number;
  nonce?: string;
  statement?: string;
  privateKey: string; // Private key to sign the message
  apiUrl?: string; // API URL for login endpoint
  email?: string;
  name?: string;
  profileImage?: string;
  referralCode?: string;
  oplCode?: string;
}

SiweLoginResult

interface SiweLoginResult {
  message: string;
  public_key: string;
  email: string;
  name: string;
  image_url: string;
  signature: string;
  referral_code: string;
  opl: string;
  isValid?: boolean;
  address?: string;
  apiResponse?: any; // Response from the login API
}

GasOptions

interface GasOptions {
  gasLimit?: bigint | string;
  maxFeePerGas?: bigint | string;
  maxPriorityFeePerGas?: bigint | string;
}

Development

# Install dependencies
npm install

# Build the project
npm run build

# Development mode (watch)
npm run dev

License

MIT