pnp-markets

0
0
Source

Create, trade, and settle prediction markets on Base with any ERC20 collateral. Use when building prediction market infrastructure, running contests, crowdsourcing probability estimates, adding utility to tokens, or tapping into true information finance via market-based forecasting.

Install

mkdir -p .claude/skills/pnp-markets && curl -L -o skill.zip "https://mcp.directory/api/skills/download/7645" && unzip -o skill.zip -d .claude/skills/pnp-markets && rm skill.zip

Installs to .claude/skills/pnp-markets

About this skill

PNP Markets

Create and manage prediction markets on Base Mainnet with any ERC20 collateral token.

Quick Decision

Need prediction markets?
├─ Create market     → npx ts-node scripts/create-market.ts --help
├─ Trade (buy/sell)  → npx ts-node scripts/trade.ts --help
├─ Settle market     → npx ts-node scripts/settle.ts --help
└─ Redeem winnings   → npx ts-node scripts/redeem.ts --help

Environment

export PRIVATE_KEY=<wallet_private_key>    # Required
export RPC_URL=<base_rpc_endpoint>         # Optional (defaults to public RPC)

For production, use a dedicated RPC (Alchemy, QuickNode) to avoid rate limits.

Scripts

Run any script with --help first to see all options.

Create Market

npx ts-node scripts/create-market.ts \
  --question "Will ETH reach $10k by Dec 2025?" \
  --duration 168 \
  --liquidity 100

Options: --collateral <USDC|WETH|address>, --decimals <n>

Trade

# Buy YES tokens
npx ts-node scripts/trade.ts --buy --condition 0x... --outcome YES --amount 10

# Sell NO tokens  
npx ts-node scripts/trade.ts --sell --condition 0x... --outcome NO --amount 5 --decimals 18

# View prices only
npx ts-node scripts/trade.ts --info --condition 0x...

Settle

# Settle as YES winner
npx ts-node scripts/settle.ts --condition 0x... --outcome YES

# Check status
npx ts-node scripts/settle.ts --status --condition 0x...

Redeem

npx ts-node scripts/redeem.ts --condition 0x...

Programmatic Usage

import { PNPClient } from "pnp-evm";
import { ethers } from "ethers";

const client = new PNPClient({
  rpcUrl: process.env.RPC_URL || "https://mainnet.base.org",
  privateKey: process.env.PRIVATE_KEY!,
});

// Create market
const { conditionId } = await client.market.createMarket({
  question: "Will X happen?",
  endTime: Math.floor(Date.now() / 1000) + 86400 * 7,
  initialLiquidity: ethers.parseUnits("100", 6).toString(),
});

// Trade
await client.trading.buy(conditionId, ethers.parseUnits("10", 6), "YES");

// Settle (after endTime)
const tokenId = await client.trading.getTokenId(conditionId, "YES");
await client.market.settleMarket(conditionId, tokenId);

// Redeem
await client.redemption.redeem(conditionId);

Collateral Tokens

Use any ERC20. Common Base Mainnet tokens:

TokenAddressDecimals
USDC0x833589fCD6eDb6E08f4c7C32D4f71b54bdA029136
WETH0x420000000000000000000000000000000000000618
cbETH0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc2218

Custom tokens add utility—holders can participate in your markets.

ERC20 Approvals

Before interacting with PNP contracts, you must approve them to spend your collateral tokens. This is standard for all EVM dApps.

How It Works

  1. First interaction requires approval: When you create a market or trade for the first time with a token, an approval transaction is sent
  2. Infinite approvals: The SDK uses type(uint256).max approvals (standard EVM pattern) so you only approve once per token
  3. Subsequent interactions: No approval needed—transactions execute directly

Timing Considerations

The approval transaction must be confirmed on-chain before the main transaction executes. If you see:

ERC20: transfer amount exceeds allowance

This means the approval hasn't been mined yet. Simply wait a few seconds and retry—the approval will be confirmed and subsequent attempts will succeed.

Why Infinite Approvals?

  • Gas efficiency: Approve once, trade forever without extra transactions
  • Better UX: No repeated approval popups
  • Industry standard: Used by Uniswap, Aave, and most major DeFi protocols

For maximum security-conscious users, you can manually set specific approval amounts, but this requires an approval transaction before each interaction.

Contracts

ContractAddress
PNP Factory0x5E5abF8a083a8E0c2fBf5193E711A61B1797e15A
Fee Manager0x6f1BffB36aC53671C9a409A0118cA6fee2b2b462

Why Prediction Markets?

  • Information Discovery: Market prices reveal collective probability estimates
  • Token Utility: Use your token as collateral to drive engagement
  • Contests: Run competitions where participants stake on outcomes
  • Forecasting: Aggregate crowd wisdom for decision-making

The pAMM virtual liquidity model ensures smooth trading even with minimal initial liquidity.

Troubleshooting

"ERC20: transfer amount exceeds allowance"

The approval transaction hasn't been confirmed yet. Wait 5-10 seconds and retry.

"Market doesn't exist"

The market creation transaction may have failed or is still pending. Verify on BaseScan that your transaction was confirmed successfully.

"over rate limit" / RPC errors

The public Base RPC has rate limits. Use a dedicated RPC provider:

export RPC_URL=https://base-mainnet.g.alchemy.com/v2/YOUR_KEY

Transaction stuck or slow

Base Mainnet can occasionally have congestion. Check gas prices and consider increasing if needed.

Reference Files

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

9521,094

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

846846

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

571700

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

548492

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

673466

fastapi-templates

wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

514280

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.