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

@forbole/kastle-sdk

v1.13.1

Published

A JavaScript library for integrating Kaspa cryptocurrency wallet functionality into web applications.

Downloads

260

Readme

@forbole/kastle-sdk

A JavaScript library for integrating Kaspa cryptocurrency wallet functionality into web applications.

npm version License: MIT

Installation

npm install @forbole/kastle-sdk

Features

  • Connect to and manage Kaspa wallets
  • Fetch balances and address information
  • Send KAS transactions
  • Handle wallet events (network changes, account changes)
  • Support for multiple networks (mainnet, testnet)

Usage

Basic Setup

Before using any SDK functions, ensure the WASM module is initialized:

import {
  wasmReady,
  connect,
  getWalletAddress,
  getBalance,
  sendKaspa
} from '@forbole/kastle-sdk';

// Wait for WASM to be ready
await wasmReady;

// Connect to the wallet
const isConnected = await connect();

if (isConnected) {
  // Get the wallet address
  const address = await getWalletAddress();
  console.log(`Connected to address: ${address}`);
  
  // Get the wallet balance
  const balance = await getBalance();
  console.log(`Balance: ${balance} sompi`);
  
  // Send KAS to another address
  const txId = await sendKaspa('kaspa:recipient_address', 1000000);
  console.log(`Transaction sent with ID: ${txId}`);
}

API Reference

WASM Initialization

wasmReady

A Promise that resolves when the Kaspa WASM module is fully loaded and initialized.

Important: Always await this Promise before using any SDK functions or the kaspaWasm module.

import { wasmReady } from '@forbole/kastle-sdk';

await wasmReady;
// Now safe to use SDK functions

kaspaWasm

Direct access to the Kaspa WASM module. Must be used after wasmReady resolves.

import { kaspaWasm, wasmReady } from '@forbole/kastle-sdk';

await wasmReady;
const address = kaspaWasm.addressFromScriptPublicKey(...);

Wallet Connection

isWalletInstalled()

Checks if a compatible Kaspa wallet provider is installed.

  • Returns: boolean

connect(networkId?)

Connects to the wallet on the specified network.

  • Parameters:
    • networkId (optional): The network to connect to (default: 'mainnet')
  • Returns: Promise<boolean> - True if connection was successful

disconnect(origin?)

Disconnects the wallet.

  • Parameters:
    • origin (optional): Origin parameter
  • Returns: Promise<void>

getNetwork()

Returns the active Kaspa network.

  • Returns: Promise<NetworkId> ('mainnet' or 'testnet')

switchNetwork(networkId)

Switches to a different Kaspa network.

  • Parameters:
    • networkId: The network to switch to
  • Returns: Promise<boolean> - True if successful

Wallet Information

getWalletAddress()

Returns the currently connected wallet address.

  • Returns: Promise<string>

getPublicKey()

Retrieves the public key associated with the wallet.

  • Returns: Promise<string>

getBalance()

Fetches the current balance of the wallet in sompi.

  • Returns: Promise<number>

getUtxoAddress(p2shAddress?)

Retrieves unspent UTXOs for the wallet.

  • Parameters:
    • p2shAddress (optional): Optional p2sh address
  • Returns: Promise<any[]>

Transactions

sendKaspa(toAddress, amountSompi, options?)

Sends Kaspa (KAS) to another address.

  • Parameters:
    • toAddress: Recipient address
    • amountSompi: Amount to send in sompi
    • options (optional): Additional options like priorityFee
  • Returns: Promise<string> - Transaction ID

Event Handling

setEventListeners(eventListeners)

Registers event listeners for account/network/balance changes.

  • Parameters:
    • eventListeners: Event listener function

removeEventListeners()

Removes all event listeners.

  • Returns: void

Features Under Development

The following features are currently under development and not yet fully implemented:

⚠️ signPskt(txJsonString, submit?, protocol?, protocolAction?, priorityFee?)

Signs a PSKT transaction for KRC20/KRC721 transfers.

⚠️ doCommitReveal(actionScript, options?)

Commits and reveals a transaction, used for minting/listing KRC assets.

⚠️ doRevealOnly(options)

Performs only the reveal phase of a commit-reveal operation.

⚠️ signMessage(msg, type?)

Signs a message using the wallet's private key and returns the signature.

⚠️ compoundUtxo()

Compounds wallet UTXOs.

Requirements

  • A compatible Kaspa wallet extension must be installed in the browser
  • Web application with JavaScript or TypeScript support

License

MIT