New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

pnp-evm

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pnp-evm

EVM SDK for PNP Prediction Markets

latest
npmnpm
Version
0.1.4
Version published
Maintainers
1
Created
Source

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

  • Build: npm run build
  • 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.

FAQs

Package last updated on 12 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts