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

@nuklai/nuklai-sdk

v0.2.4

Published

A JavaScript SDK for interacting with the Nuklai blockchain, providing modular services for HyperVM and NuklaiVM.

Downloads

66

Readme

Nuklai SDK

📦 Installation

npm install @nuklai/nuklai-sdk
# or
yarn add @nuklai/nuklai-sdk

🚀 Quick Start

import { NuklaiSDK } from "@nuklai/nuklai-sdk";

const sdk = new NuklaiSDK("http://127.0.0.1:9650");
const healthStatus = await sdk.rpcService.validateConnection();

✨ Core Features

  • 💰 Asset Management (Fungible/Non-Fungible Tokens)
  • 📊 Dataset Creation and Management
  • 🏪 Marketplace Operations
  • 💳 Transaction Management
  • 🔍 Network Status and Health Checks
  • 🏛️ Validator Management
  • 📈 Staking Operations

📖 Basic Usage

Initialization

import { NuklaiSDK } from "@nuklai/nuklai-sdk";

const sdk = new NuklaiSDK({
  baseApiUrl: "http://127.0.0.1:9650",
});

// Set the signer for transactions
sdk.rpcService.setSigner("your-private-key-here");

Asset Management

// Create a fungible token
const ftResult = await sdk.rpcService.createFTAsset(
  "Test Token",
  "TEST",
  9,
  "metadata",
  BigInt("1000000000000000000"), // Max supply
  "owner-address",
  "admin-address",
  "admin-address",
  "admin-address"
);

// Create an NFT collection
const nftResult = await sdk.rpcService.createNFTAsset(
  "Test NFT",
  "TNFT",
  "metadata",
  BigInt(1000), // Max supply
  "owner-address",
  "admin-address",
  "admin-address",
  "admin-address"
);

Token Operations

// Mint fungible tokens
const mintAmount = BigInt("1000000000000000000"); // 1 token
const mintResult = await sdk.rpcService.mintFTAsset(
  "receiver-address",
  "token-address",
  mintAmount
);

// Mint NFT
const nftMintResult = await sdk.rpcService.mintNFTAsset(
  "nft-collection-address",
  JSON.stringify({
    name: "Test NFT #1",
    description: "First NFT",
    attributes: [],
  }),
  "receiver-address"
);

// Transfer tokens
const transferAmount = BigInt("100000000000000000"); // 0.1 token
const transferResult = await sdk.rpcService.transfer(
  "recipient-address",
  "token-address",
  transferAmount,
  "Transfer memo"
);

Check Address Balance

const balance = await sdk.rpcService.getBalance("address");

Dataset Operations

// Create a dataset
const result = await sdk.rpcService.createDataset(
  "asset-address",
  "Test Dataset",
  "Description",
  "AI,Testing",
  "MIT",
  "MIT",
  "https://opensource.org/licenses/MIT",
  "metadata",
  true // isCommunityDataset
);

🛠️ Development

Build from source:

yarn
yarn build

Run tests:

yarn test

📝 Examples

The examples/ directory contains sample implementations:

examples/
├── datasets.ts            # Dataset creation and management
├── fungible-tokens.ts     # Fungible Token operations
├── non-fungible-tokens.ts # Non-Fungible Token operations
└── marketplace.ts         # Marketplace interactions

You can run all examples at once using:

yarn examples

Or run individual examples:

ts-node --esm examples/fungible-tokens.ts
ts-node --esm examples/non-fungible-tokens.ts

📚 API Reference

All methods are accessible through the sdk.rpcService instance. Below is a comprehensive reference of available methods grouped by their functionality.

Network Operations

| Method | Description | Parameters | Returns | | --------------------------- | ----------------------------- | ---------------- | ----------------------- | | validateConnection() | Checks node connectivity | None | Promise<boolean> | | getEmissionInfo() | Retrieves emission statistics | None | Promise<ActionOutput> | | getAllValidators() | Lists all validators | None | Promise<ActionOutput> | | getStakedValidators() | Lists validators with stake | None | Promise<ActionOutput> | | getValidatorStake(nodeID) | Gets specific validator stake | nodeID: string | Promise<ActionOutput> |

Asset Management

Fungible Token Methods

| Method | Description | Parameters | Returns | | ----------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | | createFTAsset() | Creates a new Fungible Token | - name: string- symbol: string- decimals: number- metadata: string- maxSupply: bigint- mintAdmin: string- pauseAdmin: string- freezeAdmin: string- kycAdmin: string | Promise<TxResult> | | mintFTAsset() | Mints Fungible Tokens | - to: string- assetAddress: string- amount: bigint | Promise<TxResult> | | transfer() | Transfers tokens | - to: string- assetAddress: string- value: bigint- memo: string | Promise<TxResult> |

Non-Fungible Token Methods

| Method | Description | Parameters | Returns | | ------------------ | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | | createNFTAsset() | Creates an NFT collection | - name: string- symbol: string- metadata: string- maxSupply: bigint- mintAdmin: string- pauseAdmin: string- freezeAdmin: string- kycAdmin: string | Promise<TxResult> | | mintNFTAsset() | Mints a new NFT | - assetAddress: string- metadata: string- to: string | Promise<TxResult> |

Dataset & Marketplace Operations

Dataset Methods

| Method | Description | Parameters | Returns | | ------------------ | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | | createDataset() | Creates a new dataset | - assetAddress: string- name: string- description: string- categories: string- licenseName: string- licenseSymbol: string- licenseURL: string- metadata: string- isCommunityDataset: boolean | Promise<TxResult> | | updateDataset() | Updates dataset info | - datasetAddress: string- name: string- description: string- categories: string- licenseName: string- licenseSymbol: string- licenseURL: string- isCommunityDataset: boolean | Promise<TxResult> | | getDatasetInfo() | Gets dataset details | datasetID: string | Promise<ActionOutput> |

Marketplace Methods

| Method | Description | Parameters | Returns | | ------------------------------- | ---------------------------- | ---------------------------------------------------------------------------------------------------------- | ------------------- | | publishDatasetToMarketplace() | Lists dataset on marketplace | - datasetAddress: string- paymentAssetAddress: string- datasetPricePerBlock: number | Promise<TxResult> | | subscribeDatasetMarketplace() | Subscribes to dataset | - marketplaceAssetAddress: string- paymentAssetAddress: string- numBlocksToSubscribe: number | Promise<TxResult> | | claimMarketplacePayment() | Claims marketplace earnings | - marketplaceAssetAddress: string- paymentAssetAddress: string | Promise<TxResult> |

Query Methods

| Method | Description | Parameters | Returns | | --------------------------- | --------------------------- | ------------------------------------------ | ----------------------- | | getBalance() | Get's address balance | address: string | Promise<string> | | getAssetInfo() | Get's asset details | assetAddress: string | Promise<ActionOutput> | | getDatasetBalance() | Get's dataset balance | - address: string- assetID: string | Promise<ActionOutput> | | getDatasetNFTInfo() | Get's NFT details | nftID: string | Promise<ActionOutput> | | getPendingContributions() | Lists pending contributions | datasetID: string | Promise<ActionOutput> |

Usage Example

Creating and minting a fungible token

// Create a FT
const ftResult = await sdk.rpcService.createFTAsset(
  "Test Token",
  "TEST",
  9,
  "metadata",
  BigInt("1000000000000000000"),
  "owner-address",
  "admin-address",
  "admin-address",
  "admin-address"
);

// After creation, mint some tokens
const mintResult = await sdk.rpcService.mintFTAsset(
  "receiver-address",
  ftResult.result[0].asset_id,
  BigInt("1000000000000000000")
);

📄 License

MIT License - see LICENSE for details.