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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@thru/token-program

v0.2.6

Published

TypeScript bindings for the Thru on-chain token program. Provides instruction builders, account parsers, address derivation, and formatting utilities for creating and managing tokens on the Thru network.

Readme

@thru/token-program

TypeScript bindings for the Thru on-chain token program. Provides instruction builders, account parsers, address derivation, and formatting utilities for creating and managing tokens on the Thru network.

Installation

pnpm add @thru/token-program

Peer dependencies: @thru/helpers, @thru/thru-sdk.

Basic Usage

Create a new token mint

import {
  createInitializeMintInstruction,
  deriveMintAddress,
} from '@thru/token-program';

const { address, bytes, derivedSeed } = deriveMintAddress(
  mintAuthorityAddress,
  seedHex,
  tokenProgramAddress
);

const instruction = createInitializeMintInstruction({
  mintAccountBytes: bytes,
  decimals: 6,
  mintAuthorityBytes: authorityBytes,
  ticker: 'MYTOKEN',
  seedHex,
  stateProof,
});

Initialize a token account

import {
  createInitializeAccountInstruction,
  deriveTokenAccountAddress,
} from '@thru/token-program';

const { bytes: tokenAccountBytes, derivedSeed } = deriveTokenAccountAddress(
  ownerAddress,
  mintAddress,
  tokenProgramAddress
);

const instruction = createInitializeAccountInstruction({
  tokenAccountBytes,
  mintAccountBytes,
  ownerAccountBytes,
  seedBytes: derivedSeed,
  stateProof,
});

Transfer tokens

import { createTransferInstruction } from '@thru/token-program';

const instruction = createTransferInstruction({
  sourceAccountBytes,
  destinationAccountBytes,
  amount: 1_000_000n,
});

Parse on-chain account data

import { parseMintAccountData, parseTokenAccountData } from '@thru/token-program';

const mintInfo = parseMintAccountData(account);
// { decimals, supply, creator, mintAuthority, freezeAuthority, ticker, ... }

const tokenInfo = parseTokenAccountData(account);
// { mint, owner, amount, isFrozen }

Format token amounts for display

import { formatRawAmount } from '@thru/token-program';

formatRawAmount(1_500_000n, 6); // "1.5"
formatRawAmount(1_000_000n, 6); // "1"

Key Capabilities

  • Instruction builders -- createInitializeMintInstruction, createInitializeAccountInstruction, createMintToInstruction, createTransferInstruction
  • Address derivation -- deriveMintAddress, deriveTokenAccountAddress, deriveWalletSeed
  • Account parsing -- parseMintAccountData, parseTokenAccountData decode raw on-chain data into typed objects
  • Formatting utilities -- formatRawAmount, bytesToHex, hexToBytes
  • ABI codegen -- instruction payloads are built using auto-generated builders from the token program ABI

API Reference

Instructions

Each instruction builder returns an InstructionData function that accepts an AccountLookupContext and resolves to the serialized instruction bytes.

| Function | Description | |---|---| | createInitializeMintInstruction(args) | Create a new token mint with ticker, decimals, and authorities | | createInitializeAccountInstruction(args) | Create a token account for a given owner and mint | | createMintToInstruction(args) | Mint new tokens to a destination account | | createTransferInstruction(args) | Transfer tokens between accounts | | buildTokenInstructionBytes(variant, payload) | Low-level helper to wrap a payload in a token instruction envelope |

Derivation

| Function | Description | |---|---| | deriveMintAddress(authority, seed, programAddress) | Derive the deterministic address for a token mint | | deriveTokenAccountAddress(owner, mint, programAddress, seed?) | Derive the deterministic address for a token account | | deriveWalletSeed(walletAddress, extraSeeds?) | Derive a seed from a wallet address |

Account Parsing

| Function | Description | |---|---| | parseMintAccountData(account) | Parse raw account data into MintAccountInfo | | parseTokenAccountData(account) | Parse raw account data into TokenAccountInfo | | isAccountNotFoundError(err) | Check if an error represents a missing account (code 5) |

Types

interface MintAccountInfo {
  decimals: number;
  supply: bigint;
  creator: string;
  mintAuthority: string;
  freezeAuthority: string | null;
  hasFreezeAuthority: boolean;
  ticker: string;
}

interface TokenAccountInfo {
  mint: string;
  owner: string;
  amount: bigint;
  isFrozen: boolean;
}

Constants

| Constant | Value | Description | |---|---|---| | PUBKEY_LENGTH | 32 | Length of a public key in bytes | | TICKER_MAX_LENGTH | 8 | Maximum ticker string length | | ZERO_PUBKEY | Uint8Array(32) | 32 zero bytes, used as a null public key |

Build

pnpm build    # Build with tsup (CJS + ESM + .d.ts)
pnpm dev      # Watch mode
pnpm clean    # Remove dist/