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

v1.0.1

Published

EVM SDK for PNP Prediction Markets on Monad

Readme

monad-sdk

The official TypeScript SDK for creating and trading prediction markets on Monad.

This SDK provides a high-level abstraction over the on-chain smart contracts (MarketFactory, FeeManager), enabling developers to programmatically create prediction markets, trade outcome tokens (YES/NO), and redeem winnings — all through a clean, typed interface.

Highlights

  • One-line market creation — Spin up a fully on-chain prediction market with a single function call. Question, liquidity, deadline — done.
  • Built on Monad — Harness 10,000 TPS and sub-second finality. No more waiting around for block confirmations on sluggish L1s.
  • Permissionless and composable — Any developer, any agent, any bot can create markets, trade outcomes, and settle positions. No gatekeepers.
  • Auto-pilot approvals — The SDK handles ERC20 allowance checks and approvals under the hood. You just say "buy" and it figures out the rest.
  • Battle-tested AMM pricing — Built-in CPMM with real-time YES/NO price feeds. Market odds update live with every trade.
  • Agent-ready architecture — Designed for AI agents to autonomously create and trade prediction markets. npm install pnp-monad and let your agent loose.
  • Type-safe and zero-config — Full TypeScript support with pre-loaded Monad contract addresses. Import, initialize, ship.
  • Open source, public npm — Install with npm install pnp-monad. Fully open, fully auditable, no black boxes.

Installation

npm install pnp-monad

Quick Start

1. Initialize the Client

import { PNPClient } from "pnp-monad";

const client = new PNPClient({
  // Defaults to the Monad mainnet RPC if omitted
  rpcUrl: process.env.RPC_URL,
  // Required for any write operations (market creation, trading, redemption)
  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)
});

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

The createMarket method handles collateral approval automatically if the factory's allowance is insufficient.

3. Trade (Buy / Sell)

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

// Sell 5 YES outcome tokens back for collateral
const sellAmount = ethers.parseUnits("5", 18); // Outcome tokens use 18 decimals
await client.trading.sell(conditionId, sellAmount, "YES");

Both buy and sell accept an optional minTokensOut / minCollateralOut parameter for slippage protection.

4. Fetch Market Info

const info = await client.market.getMarketInfo(conditionId);
console.log(info);

Returns an object containing:

| Field | Description | |---|---| | question | The market's question string | | endTime | Unix timestamp when trading closes | | isCreated | Whether the market exists on-chain | | isSettled | Whether the market has been resolved | | reserve | Total collateral held in the market | | collateral | Address of the collateral token | | winningToken | Token ID of the winning outcome (0 if unsettled) |

5. Get Market Prices

const prices = await client.market.getMarketPrices(conditionId);
console.log(prices.yesPricePercent); // e.g. "70.00%"
console.log(prices.noPricePercent);  // e.g. "30.00%"

6. Redeem Winnings

After a market is settled, holders of the winning outcome token can redeem their collateral:

const isResolved = await client.redemption.isResolved(conditionId);
if (isResolved) {
  await client.redemption.redeem(conditionId);
}

Configuration

The SDK ships with default contract addresses for Monad:

| Contract | Address | |---|---| | Factory | 0xDD5975B6D29C73e9e68FF128c1B5B4244986CF66 | | FeeManager | 0x9ac2dc5fB9a6b95CA9dEa27063f10e09e55fEfFa | | Collateral | 0x350035555E10d9AfAF1566AaebfCeD5BA6C27777 |

To override the defaults (e.g. for a different chain or custom deployment):

const client = new PNPClient({
  rpcUrl: "https://your-rpc-url.com",
  privateKey: "...",
  contractAddresses: {
    marketFactory: "0x...",
    usdcToken: "0x...",
    feeManager: "0x...",
  },
});

Development

  1. Build the SDK: npm run build
  2. Run the example script:
    export PRIVATE_KEY="your_hex_private_key"
    npx ts-node examples/quickstart.ts

Error Handling

The SDK includes custom error parsing for common contract reverts such as InvalidMarketEndTime, MarketTradingStopped, InvalidAddress, and InvalidTokenId. Read operations automatically retry on RPC rate-limit errors with exponential backoff (up to 5 attempts).