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

kasplex-api

v1.0.6

Published

A library that uses the kasplex api

Downloads

478

Readme

Kasplex API Library

The Kasplex API Library is a TypeScript library for interacting with the Kasplex blockchain API, allowing developers to manage KRC-20 tokens, query token information, and perform operations seamlessly.

Table of Contents

Installation

To install the Kasplex API Library, run:

yarn add kasplex-api

Usage

To use the library, import the Kasplex class into your TypeScript project and instantiate it with the desired network type (either mainnet or testnet).

import { Kasplex } from 'kasplex-api';

const kasplex = new Kasplex('mainnet');

Methods

getTokenInfo(tick: string)

Get details of a specific KRC-20 token by its tick.

Parameters:

  • tick: A string representing the token's tick.

Returns:

A promise that resolves to an object containing the token details.

Example:

const tokenInfo = await kasplex.getTokenInfo('KASCOW');

console.log(tokenInfo);

All values that use decimals are auto transformed including the holders amount

Output:

{
  "message": "successful",
  "result": {
    "tick": "KASCOW",
    "max": 27000000000,
    "lim": 12000,
    "pre": 3500000000,
    "to": "kaspa:qpgthce84ql2yljlz95c2cgqjl7f3s4k5xwt3svaad8glrjujjdvznqgsgfs7",
    "dec": "8",
    "minted": 3525752000,
    "opScoreAdd": "920701630000",
    "opScoreMod": "940039580002",
    "state": "deployed",
    "hashRev": "87f682324a07e17639808f7c5275fe220716ab6bea42c4eceb84d0776706d34f",
    "mtsAdd": "1728379050363",
    "holderTotal": "39",
    "transferTotal": "64",
    "mintTotal": "2146",
    "holder": []
  }
}

getTokenList(params?: { next?: string; prev?: string })

Retrieve a list of KRC-20 tokens with pagination.

Parameters:

  • params (optional): An object containing pagination parameters.
    • next: The next page token.
    • prev: The previous page token.

Returns:

A promise that resolves to an object containing a list of tokens and pagination information.

Example:

const tokenList = await kasplex.getTokenList();

console.log(tokenList);

Output:

{
  "message": "successful",
  "result": [
    {
      "tick": "STICK",
      "max": 1000000000,
      "lim": 1000,
      "pre": 0,
      "to": "kaspa:qzy5hky57ay46a5fyy6x8dk24prah3xndnvwnndr8q9xn303r40zvrvhwt38n",
      "dec": "8",
      "minted": 1000000000,
      "opScoreAdd": "938559700010",
      "opScoreMod": "938605630084",
      "state": "finished",
      "hashRev": "7c4ae5b1705cc56d5ab223fc191380b4f57ab619375390d930f012f5f5ad6fc1",
      "mtsAdd": "1730150794525"
    },
    ...
  ],
  "next": "938111120000",
  "prev": "941145300005"
}

getTokenListOfAddress(address: string, params?: { next?: string; prev?: string })

Get a list of KRC-20 tokens held by a specific address.

Parameters:

  • address: The holder address (case-insensitive).
  • params (optional): Pagination parameters.

Returns:

A promise that resolves to an object containing token balances for the specified address.

Example:

const addressTokens = await kasplex.getTokenListOfAddress('yourAddressHere');
console.log(addressTokens);

getTokenBalanceOfAddress(address: string, tick: string)

Get the balance of a specific KRC-20 token for a given address.

Parameters:

  • address: The holder address.
  • tick: The token's tick.

Returns:

A promise that resolves to an object containing the token balance for the specified address.

Example:

const tokenBalance = await kasplex.getTokenBalanceOfAddress('yourAddressHere', 'KASCOW');
console.log(tokenBalance);

getOpList(params?: { next?: string; prev?: string; address?: string; tick?: string })

Get a list of KRC-20 operations with optional filtering.

Parameters:

  • params (optional): An object containing filtering parameters.
    • next: The next page token.
    • prev: The previous page token.
    • address: The address to filter operations.
    • tick: The token tick to filter operations.

Returns:

A promise that resolves to an object containing a list of operations and pagination information.

Example:

const operations = await kasplex.getOpList();
console.log(operations);

getOpDetails(operationId: string)

Get details of a specific KRC-20 operation.

Parameters:

  • operationId: The ID of the operation.

Returns:

A promise that resolves to an object containing the operation details.

Example:

const operationDetails = await kasplex.getOpDetails('operationIdHere');
console.log(operationDetails);

Contributing

Contributions are welcome! Please feel free to submit a pull request or create an issue to discuss any features or bugs.

License

This project is licensed under the MIT License - see the LICENSE file for details.