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

@glittr-sdk/sdk

v0.18.1

Published

The Glittr-SDK is a JavaScript/TypeScript library that provides a simple interface for interacting with the Glittr ecosystem. It allows you to create and broadcast Glittr transactions, such as Create FT Contract, Mint, Transfer, etc.

Downloads

934

Readme

Glittr Client SDK

The Glittr-SDK is a JavaScript/TypeScript library that provides a simple interface for interacting with the Glittr ecosystem. It allows you to create and broadcast Glittr transactions, such as Create FT Contract, Mint, Transfer, etc.

Installation

To use the Glittr-SDK, you'll need to install it as a dependency in your project:

npm install @glittr-sdk/sdk

Usage

Here's an example of how to use the Glittr-SDK to create and broadcast a transaction:

import { Account, GlittrSDK, txBuilder } from "@glittr-sdk/sdk";

async function main() {
  const NETWORK = "regtest";
  const client = new GlittrSDK({
    network: NETWORK,
    electrumApi: "https://devnet-electrum.glittr.fi",
    glittrApi: "https://devnet-core-api.glittr.fi",
  });

  const account = new Account({
    wif: "your WIF here",
    network: NETWORK,
  });

  const c = txBuilder.freeMintContractInstantiate({
    simple_asset: {
      supply_cap: 2000n.toString(),
      divisibility: 18,
      live_time: 0,
    },
    amount_per_mint: 2n.toString(),
  });

  const txid = await client.createAndBroadcastTx({
    account: account.p2pkh(),
    tx: c,
    outputs: [],
  });

  console.log("TXID : ", txid);
}

main();

APIs

GlittrSDK

Constructor

constructor({ network, glittrApi, electrumApi }: GlittrSDKParams)

Parameters:

  • network (Network): The Bitcoin network to use (e.g., 'mainnet', 'testnet', 'regtest').
  • glittrApi (string): The URL of the Glittr API endpoint.
  • electrumApi (string): The URL of the Electrum API endpoint.

createAndBroadcastTx

async createAndBroadcastTx({
  account,
  tx,
  outputs,
  utxos,
}: CreateBroadcastTxParams): Promise<string>

Parameters:

  • account (P2pkhAccount | P2wpkhAccount): The Bitcoin account to use for the transaction.
  • tx (TransactionFormat): The Glittr transaction to be created and broadcast.
  • outputs (Output[]): Additional transaction outputs (besides the Glittr-specific output).
  • utxos (BitcoinUTXO[]): The unspent transaction outputs to use as inputs for the transaction.

Returns:

  • Promise<string>: The transaction ID of the broadcasted transaction.

Account

Constructor

constructor({ privateKey, wif, network }: AccountParams)

Parameters:

  • privateKey (string, optional): The private key of the Bitcoin account.
  • wif (string, optional): The Wallet Import Format (WIF) of the Bitcoin account.
  • network (Network): The Bitcoin network to use (e.g., 'mainnet', 'testnet', 'regtest').

p2pkh

p2pkh(): P2pkhAccount

Returns:

  • P2pkhAccount: An account object with a P2PKH (Pay-to-Public-Key-Hash) address and keypair.

p2wpkh

p2wpkh(): P2wpkhAccount

Returns:

  • P2wpkhAccount: An account object with a P2WPKH (Pay-to-Witness-Public-Key-Hash) address and keypair.

txBuilder

transfer

static transfer(params: TransferParams): TransferFormat

Parameters:

  • params (TransferParams): Parameters for the transfer transaction.

Returns:

  • TransferFormat: The transfer transaction format.

freeMintContractInstantiate

static freeMintContractInstantiate(
  params: FreeMintContractParams
): FreeMintContractInstantiateFormat

Parameters:

  • params (FreeMintContractParams): Parameters for the Free Mint Contract Instantiate transaction.

Returns:

  • FreeMintContractInstantiateFormat: The Free Mint Contract Instantiate transaction format.

preallocatedContractInstantiate

static preallocatedContractInstantiate(
  params: PreallocatedContractParams
): PreallocatedContractFormat

Parameters:

  • params (PreallocatedContractParams): Parameters for the Preallocated Contract Instantiate transaction.

Returns:

  • PreallocatedContractFormat: The Preallocated Contract Instantiate transaction format.

purchaseBurnSwapContractInstantiate

static purchaseBurnSwapContractInstantiate(
  params: PurchaseBurnContractParams
): PurchaseBurnContractFormat

Parameters:

  • params (PurchaseBurnContractParams): Parameters for the Purchase Burn Swap Contract Instantiate transaction.

Returns:

  • PurchaseBurnContractFormat: The Purchase Burn Swap Contract Instantiate transaction format.

mint

static mint(params: MintContractCallParams): MintContractCallFormat

Parameters:

  • params (MintContractCallParams): Parameters for the Mint transaction.

Returns:

  • MintContractCallFormat: The Mint transaction format.

buildMessage

static buildMessage(m: OpReturnMessage): OpReturnMessage

Parameters:

  • m (OpReturnMessage): The OP_RETURN message to be built.

Returns:

  • OpReturnMessage: The built OP_RETURN message.