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

kp-is-the-best

v0.1.0

Published

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

Downloads

57

Readme

Nuklai SDK

The Nuklai SDK provides a modular and comprehensive interface for interacting with the Nuklai blockchain. It is designed to facilitate developers with functions ranging from network configurations to transaction management and complex warp operations.

Features

  • Core and Nuklai API Services: Separate interfaces for HyperVM (coreapi) and NuklaiVM (nuklaivm) functionalities.
  • Network Services: Fetch network settings and last accepted blocks.
  • Health Checks: Monitor the liveness and connectivity of the blockchain network.
  • Transaction Management: Submit and fetch details about transactions.
  • Asset Management: Query and manage blockchain assets.
  • Emission Details: Access emission information, validator details, and staking functionalities.

Installation

Install the Nuklai SDK via npm/yarn (NOTE: Currently does not work, so you need to build it locally):

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

Build from Source

To build the SDK from source:

yarn
yarn build

Examples

The examples directory contains various example code to interact with the Nuklai SDK.

Usage

Import and initialize the SDK in your project:

import { NuklaiSDK } from '@nuklai/nuklai-sdk'

const sdk = new NuklaiSDK({
  baseApiUrl: 'http://127.0.0.1:9650', // Node API URL
  blockchainId: 'CuH4wPFDk6p1jSRPMcJPgt9nGFfF7zfRrH3nkJW2TWLfRE53L' // Blockchain ID
})

Example Usage

Check Health Status

const healthStatus = await sdk.hyperApiService.ping()
console.log('Node Ping:', JSON.stringify(healthStatus, null, 2))

Get Network Information

const networkInfo = await sdk.hyperApiService.getNetworkInfo()
console.log('Network Info:', JSON.stringify(networkInfo, null, 2))

Fetch a Balance

const params = {
  address: 'nuklai1qpg4ecapjymddcde8sfq06dshzpxltqnl47tvfz0hnkesjz7t0p35d5fnr3',
  asset: 'NAI'
}
const balance = await sdk.assetService.getBalance(params)
console.log('Balance:', JSON.stringify(balance, null, 2))

Fetch Emission Information

const emissionInfo = await sdk.emissionService.getEmissionInfo()
console.log('Emission Info:', JSON.stringify(emissionInfo, null, 2))

Generate Private/Public Key Pair

import { NuklaiSDK, auth } from '@nuklai/nuklai-sdk'
const { privateKey, publicKey } = auth.ED25519Factory.generateKeyPair()
console.log(
  'Generated ED25519 Private Key:',
  auth.ED25519Factory.privateKeyToHex(privateKey)
)
console.log(
  'Generated ED25519 Public Key:',
  auth.ED25519.publicKeyToHex(publicKey)
)

Submit a Transaction

// Set the private key for the sender address
const authFactory = auth.getAuthFactory(
  'ed25519',
  '323b1d8f4eed5f0da9da93071b034f2dce9d2d22692c172f3cb252a64ddfafd01b057de320297c29ad0c1f589ea216869cf1938d88c9fbd70d6748323dbf2fa7' // private key (as hex string) for nuklai1qrzvk4zlwj9zsacqgtufx7zvapd3quufqpxk5rsdd4633m4wz2fdjss0gwx
)
const txID = await sdk.transactionService.sendTransferTransaction(
  'nuklai1qpxncu2a69l9wyz3yqg4fqn86ys2ll6ja7vhym5qn2vk4cdyvgj2vn4k7wz', // receiver address
  'NAI', // asset ID
  '0.0001', // amount
  'Test Memo', // memo
  authFactory
)
console.log('Transaction ID:', txID)

Contributing

Contributions to the Nuklai SDK are welcome! Please ensure that your code adheres to the existing style, and include tests for new features.

License

This SDK is released under the MIT License.

This README file should provide a clear and professional introduction to your SDK, making it easier for developers to understand how to use it and contribute to it.