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

pnp-sdk

v0.2.3

Published

Production-ready SDK for Solana prediction markets: create markets, trade, and redeem positions.

Readme

pnp-sdk

Production-ready SDK for Solana prediction markets: create markets, trade, and redeem positions.

Install

npm i pnp-sdk

Usage (Node)

Environment Setup

Create a .env file with the following variables:

# Solana RPC URL (mainnet, devnet, testnet, or local)
RPC_URL=https://api.devnet.solana.com

# Wallet private key (as Base58 string or array)
WALLET_SECRET_BASE58=YourBase58EncodedPrivateKeyHere
# OR as array
WALLET_SECRET_ARRAY=[38,217,47,162,6,...] # your array of numbers

# Program ID is embedded in the program IDL; no env needed

# Optional: Mint addresses for market creation
BASE_MINT=YourBaseMintAddressHere
QUOTE_MINT=YourQuoteMintAddressHere

With Base58 Private Key

import { PNPClient } from "pnp-sdk";
import bs58 from "bs58";
import * as dotenv from "dotenv";

dotenv.config();

const maybePk = process.env.WALLET_SECRET_BASE58 ? bs58.decode(process.env.WALLET_SECRET_BASE58) : undefined;
const client = new PNPClient(process.env.RPC_URL!, maybePk);

// Read-only
const global = await client.fetchGlobalConfig();
// With private key present, you can access write modules:
// await client.trading!.buyTokensUsdc(...)

With Private Key Array

import { PNPClient } from "pnp-sdk";
import * as dotenv from "dotenv";

dotenv.config();

const privateKeyArray = JSON.parse(process.env.WALLET_SECRET_ARRAY!);
const privateKeyBytes = new Uint8Array(privateKeyArray);
const client = new PNPClient(process.env.RPC_URL!, privateKeyBytes);

Development

  • Build: npm run build
  • Test: npm test
  • Typecheck: npm run typecheck

REST API Server

The SDK includes an Express server implementation that allows you to create markets via HTTP endpoints:

# Start the API server
npm run api:server

# Access the API at http://localhost:3000

API Endpoints

  • GET /health - Health check endpoint
  • POST /create-market - Create a new market
    • Request body: { "question": "Your market question here" }

Command Line Interface

You can also create markets directly from the command line:

# Create a market with a specific question
npm run api:server "Will this market prediction come true?"

Example Response

{
  "success": true,
  "txSignature": "2NPJ3NCuP1EZpN8DAwyjUgKJbRNZ6ZzmLSz8gXq3wMARMjeY3Y8xpGKUQo4hjiP7eoqAa6bHLNvWUbHMRGZ1sk9n",
  "market": "CL9tjeJL38C3KyVvUxSHiiMzfvvB6gNn6TCweE9TH45t",
  "yesTokenMint": "BzPKqzBNKw3hjj7BNn6oT7GXG3LKv7R1mFQby5bAYvdG",
  "noTokenMint": "5ctuKQpZMQ2HoMvjXZHxAT3QxCN5mq8Ss1U5YCvFg8aZ",
  "marketDetails": {
    "id": "42",
    "question": "Will this market prediction come true?",
    "creator": "BUbQNJKKRvZesSPbgJyw1nHDRNMn7demZjcaqWpLXcFe",
    "initialLiquidity": "50000000",
    "marketReserves": "50000000",
    "yesTokenSupply": "50000000",
    "noTokenSupply": "50000000",
    "endTime": "2025-08-27T19:12:28.000Z",
    "resolved": false
  }
}

Next steps

  • Replace placeholder instruction data encodings with your program's IDL/Borsh schemas.
  • Add account metas per instruction (vaults, ATAs, mints, PDAs).
  • Expand tests to integration against solana-test-validator.