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

loncher-sdk

v1.0.1

Published

JavaScript SDK for interacting with the Loncher token launchpad platform

Readme

Loncher SDK

A simple JavaScript/TypeScript SDK for interacting with the Loncher token launchpad platform on Binance Smart Chain.

Installation

npm install loncher-sdk ethers@6

Quick Start

import { LoncherSDK } from 'loncher-sdk';
import { parseEther, Wallet, JsonRpcProvider } from 'ethers';

// Create a signer
const provider = new JsonRpcProvider('https://bsc-dataseed.binance.org');
const signer = new Wallet('0x...your_private_key', provider);

// Initialize the SDK
const sdk = new LoncherSDK({
  factoryAddress: '0x236a6B18E30C6073849653cc0f1c46985FD06A8c',
  indexerAddress: '0xb7AB1e21E3A44243361DBa42d8d72213535C083C',
  signer, // Pass ethers Signer instance
});

// Deploy a new token with initial buy
const result = await sdk.factory.deployToken({
  name: 'My Token',
  symbol: 'MTK',
  metadata: JSON.stringify({ description: 'My awesome token' }),
  configId: 0, // Liquidity configuration ID
  initialBuyBNB: parseEther('0.1'), // Buy 0.1 BNB worth on deploy
});

console.log('Token deployed at:', result.tokenAddress);
console.log('Tokens received:', result.tokensReceived);

// Get token information
const tokenInfo = await sdk.factory.getTokenInfo(result.tokenAddress);
console.log('Token name:', tokenInfo.name);
console.log('Market cap:', tokenInfo.marketCapInBNB);

// Interact with the token
const token = sdk.getToken(result.tokenAddress);
const balance = await token.balanceOf(await sdk.getSignerAddress());
console.log('My balance:', balance);

Features

Factory Contract

Deploy and manage tokens on the Loncher platform:

// Deploy a new token
const deployment = await sdk.factory.deployToken({
  name: 'My Token',
  symbol: 'MTK',
  metadata: JSON.stringify({
    description: 'Token description',
    image: 'https://...',
    website: 'https://...',
  }),
  configId: 0,
  initialBuyBNB: parseEther('0.1'),
});

// Get token info
const info = await sdk.factory.getTokenInfo(tokenAddress);

// Get all tokens by deployer
const tokens = await sdk.factory.getTokensByDeployer(deployerAddress);

// Get paginated token list
const page0 = await sdk.factory.getDeploysByPage(0, 0); // newest first

// Get token market cap
const marketCap = await sdk.factory.getTokenMarketCap(tokenAddress);

// Collect fees and execute buyback
const feeResult = await sdk.factory.collectFeesAndBuyback(tokenAddress);
console.log('BNB fees collected:', feeResult.wbnbFeesCollected);
console.log('Tokens burned:', feeResult.tokensBoughtAndBurned);

Token Contract

Interact with deployed tokens (standard ERC20 + custom features):

const token = sdk.getToken(tokenAddress);

// Standard ERC20 functions
const name = await token.name();
const symbol = await token.symbol();
const totalSupply = await token.totalSupply();
const balance = await token.balanceOf(address);

// Transfer tokens
await token.transfer(recipientAddress, parseEther('100'));

// Approve spender
await token.approve(spenderAddress, parseEther('1000'));

// Burn tokens
await token.burn(parseEther('50'));

// Get token pair info (pool, token, factory)
const pair = await token.getTokenPair();
console.log('Pool address:', pair.pool);

// Check if launch period is active (first 5 blocks with trading limits)
const isLaunchActive = await token.isLaunchPeriodActive();

Indexer Contract

Listen to platform events and query historical data:

// Listen for new token deployments
sdk.indexer.onTokenCreated((event) => {
  console.log('New token deployed:', event.tokenAddress);
  console.log('Deployer:', event.deployer);
  console.log('Timestamp:', event.timestamp);
});

// Listen for buy events on a specific token
sdk.indexer.onBuy((event) => {
  console.log('Buy:', event.amountTokens);
  console.log('Price:', event.priceX96);
}, tokenAddress);

// Listen for sell events
sdk.indexer.onSell((event) => {
  console.log('Sell:', event.amountTokens);
  console.log('Trader:', event.trader);
});

// Query historical events
const fromBlock = 12345678;
const tokens = await sdk.indexer.queryTokenCreated(fromBlock);
const buys = await sdk.indexer.queryBuyEvents(fromBlock, 'latest', tokenAddress);
const sells = await sdk.indexer.querySellEvents(fromBlock);

// Stop listening to events
sdk.indexer.removeAllListeners();

Configuration

Default Contract Addresses (BSC Mainnet)

const FACTORY_ADDRESS = '0x236a6B18E30C6073849653cc0f1c46985FD06A8c';
const INDEXER_ADDRESS = '0xb7AB1e21E3A44243361DBa42d8d72213535C083C';

Initialize with RPC URL (Read-only)

const sdk = new LoncherSDK({
  factoryAddress: '0x236a6B18E30C6073849653cc0f1c46985FD06A8c',
  indexerAddress: '0xb7AB1e21E3A44243361DBa42d8d72213535C083C',
  rpcUrl: 'https://bsc-dataseed.binance.org',
});

Initialize with Signer (For Transactions)

import { Wallet, JsonRpcProvider } from 'ethers';

const provider = new JsonRpcProvider('https://bsc-dataseed.binance.org');
const signer = new Wallet('0x...your_private_key', provider);

const sdk = new LoncherSDK({
  factoryAddress: '0x236a6B18E30C6073849653cc0f1c46985FD06A8c',no, 
  indexerAddress: '0xb7AB1e21E3A44243361DBa42d8d72213535C083C',
  signer, // Pass ethers Signer instance
});

Initialize with Browser Wallet (MetaMask)

import { BrowserProvider } from 'ethers';

// Get signer from MetaMask
const provider = new BrowserProvider(window.ethereum);
const signer = await provider.getSigner();

const sdk = new LoncherSDK({
  factoryAddress: '0x236a6B18E30C6073849653cc0f1c46985FD06A8c',
  indexerAddress: '0xb7AB1e21E3A44243361DBa42d8d72213535C083C',
  signer, // User's wallet signer
});

Initialize with Custom Provider

import { JsonRpcProvider } from 'ethers';

const provider = new JsonRpcProvider('https://bsc-dataseed.binance.org');

const sdk = new LoncherSDK({
  factoryAddress: '0x236a6B18E30C6073849653cc0f1c46985FD06A8c',
  indexerAddress: '0xb7AB1e21E3A44243361DBa42d8d72213535C083C',
  provider,
});

Utilities

// Verify connected to BSC mainnet
await sdk.verifyNetwork();

// Get current block number
const blockNumber = await sdk.getBlockNumber();

// Get BNB balance
const balance = await sdk.getBNBBalance(address);

// Get signer address
const myAddress = await sdk.getSignerAddress();

// Check if signer is configured
if (sdk.hasSigner()) {
  // Can sign transactions
}

// Get constant addresses
const wbnb = sdk.getWBNBAddress();
const router = sdk.getSwapRouterAddress();

// Cleanup
sdk.disconnect();

Constants

The SDK exports useful constants:

import {
  PANCAKE_V3_POSITION_MANAGER,
  PANCAKE_V3_SWAP_ROUTER,
  PANCAKE_V3_FACTORY,
  WBNB_ADDRESS,
  FEE_TIER_10000,
  BSC_CHAIN_ID,
  BSC_TESTNET_CHAIN_ID,
} from 'loncher-sdk';

TypeScript Support

The SDK is written in TypeScript and exports all types:

import {
  TokenInfo,
  LiquidityConfig,
  DeployTokenOptions,
  DeployTokenResult,
  FeeCollectionResult,
  TradeEvent,
  TokenCreatedEvent,
  TokenPair,
} from 'loncher-sdk';

Examples

Deploy Token with Metadata

const result = await sdk.factory.deployToken({
  name: 'Super Token',
  symbol: 'SUPER',
  metadata: JSON.stringify({
    description: 'A super cool token',
    image: 'ipfs://...',
    website: 'https://supertoken.io',
    telegram: 'https://t.me/supertoken',
    twitter: 'https://twitter.com/supertoken',
  }),
  configId: 0,
  initialBuyBNB: parseEther('1'), // Buy 1 BNB worth on deploy
});

Monitor All Platform Activity

// Listen to all new tokens
sdk.indexer.onTokenCreated((event) => {
  console.log(`New token: ${event.tokenAddress}`);
});

// Listen to all buys
sdk.indexer.onBuy((event) => {
  console.log(`Buy on ${event.token}: ${event.amountTokens}`);
});

// Listen to all sells
sdk.indexer.onSell((event) => {
  console.log(`Sell on ${event.token}: ${event.amountTokens}`);
});

Get Token Statistics

const tokenAddress = '0x...';

// Get basic info
const info = await sdk.factory.getTokenInfo(tokenAddress);
console.log('Name:', info.name);
console.log('Symbol:', info.symbol);
console.log('Deployer:', info.deployer);
console.log('Market Cap:', info.marketCapInBNB);

// Get token details
const token = sdk.getToken(tokenAddress);
const totalSupply = await token.totalSupply();
const pair = await token.getTokenPair();

// Get fees
const feesGenerated = await sdk.factory.getTokenFeesGenerated(tokenAddress);
const feesClaimed = await sdk.factory.getTokenFeesClaimed(tokenAddress);

Query Trading History

const fromBlock = 12345678;
const tokenAddress = '0x...';

// Get all buys for a token
const buys = await sdk.indexer.queryBuyEvents(fromBlock, 'latest', tokenAddress);
buys.forEach(buy => {
  console.log(`Buyer: ${buy.trader}, Amount: ${buy.amountTokens}`);
});

// Get all sells for a token
const sells = await sdk.indexer.querySellEvents(fromBlock, 'latest', tokenAddress);
sells.forEach(sell => {
  console.log(`Seller: ${sell.trader}, Amount: ${sell.amountTokens}`);
});

Error Handling

try {
  const result = await sdk.factory.deployToken({
    name: 'My Token',
    symbol: 'MTK',
    metadata: '{}',
    configId: 0,
  });
} catch (error) {
  if (error.code === 'INSUFFICIENT_FUNDS') {
    console.error('Not enough BNB for gas');
  } else if (error.message.includes('DeploymentDisabled')) {
    console.error('Token deployment is currently disabled');
  } else {
    console.error('Error:', error.message);
  }
}

License

MIT

Support

For issues and questions: