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-evm

v0.1.4

Published

EVM SDK for PNP Prediction Markets

Downloads

575

Readme

pnp-evm

The official TypeScript SDK for interacting with the PNP Prediction Market Protocol on EVM-compatible chains (defaulting to Base Mainnet).

This SDK provides a high-level abstraction over the smart contracts (PNPFactory, FeeManager), allowing developers to easily create markets, trade outcome tokens, and redeem winnings.

Features

  • 🚀 Easy Integration: Simple methods for createMarket, buy, sell, and redeem.
  • 🛡️ Robust: Built-in retry mechanisms and rate-limit handling for public RPCs.
  • ⚡️ Base Ready: Pre-configured with official Base Mainnet contract addresses.
  • 🔌 Flexible: Works with any EVM chain by providing custom contract addresses.

Installation

cd evm_pnp_sdk
npm install
npm run build

Quick Start

1. Initialize the Client

import { PNPClient } from "pnp-evm";

const client = new PNPClient({
  // Optional: Defaults to "https://mainnet.base.org"
  rpcUrl: process.env.RPC_URL, 
  // Required for transactions
  privateKey: process.env.PRIVATE_KEY 
});

2. Create a Market

import { ethers } from "ethers";

const endTime = Math.floor(Date.now() / 1000) + 86400; // 24 hours from now

const { conditionId, receipt } = await client.market.createMarket({
  question: "Will ETH hit $5000 in 2025?",
  endTime: endTime,
  initialLiquidity: "1000000", // 1 USDC (6 decimals)
  // collateralToken: "0x..." // Optional: Defaults to USDC on Base
});

console.log(`Market Created: ${conditionId}`);

3. Trade (Buy/Sell)

// Buy "YES" shares
const buyAmount = ethers.parseUnits("10", 6); // 10 USDC
await client.trading.buy(conditionId, buyAmount, "YES");

// Sell "YES" shares
const sellAmount = ethers.parseUnits("5", 18); // 5 Outcome Tokens (18 decimals)
await client.trading.sell(conditionId, sellAmount, "YES");

4. Fetch Market Info

const info = await client.market.getMarketInfo(conditionId);
console.log(info);
/* Output:
{
  question: "Will ETH hit $5000 in 2025?",
  endTime: "173...",
  isCreated: true,
  isSettled: false,
  reserve: "1000000...",
  winningToken: "0"
}
*/

Configuration

The SDK comes pre-configured for Base Mainnet:

| Contract | Address | |PO|---| | Factory | 0x66177AC64968b348393Dd05b1664935947832D9E | | FeeManager | 0xaA9C0a95b257588b9574fD9BfBf040309073bcA7 | | USDC | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |

To use a different chain or contracts:

const client = new PNPClient({
  rpcUrl: "https://eth-mainnet.alchemyapi.io/...",
  privateKey: "...",
  contractAddresses: {
    marketFactory: "0x...",
    usdcToken: "0x...",
    feeManager: "0x..."
  }
});

Development

  1. Build: npm run build
  2. Run Example:
    export PRIVATE_KEY="your_key"
    npx ts-node examples/quickstart.ts

Error Handling

The SDK includes custom error parsing for common contract reverts (e.g., Invalid amount, Slippage protection). It also automatically handles "Rate Limit" errors from public RPC nodes by retrying read operations.