Skip to main content
ClaudeWave
Skill5.3k repo starsupdated 17d ago

pnp-markets-solana

Create, trade, and settle permissionless prediction markets on Solana. Use when building prediction market infrastructure, creating social media markets (Twitter/YouTube/DeFiLlama), setting up custom oracle resolution, P2P betting, or autonomous agent-driven forecasting. Supports V2 AMM, P2P (V3), and custom oracle markets with any SPL token collateral (including Token-2022).

Install in Claude Code
Copy
git clone --depth 1 https://github.com/internet-court/internet-court-skill /tmp/pnp-markets-solana && cp -r /tmp/pnp-markets-solana/vendored/pnp/pnp-solana ~/.claude/skills/pnp-markets-solana
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# PNP Markets (Solana)

Create and manage prediction markets on Solana with any SPL token collateral. Supports V2 AMM markets, P2P direct bets, custom oracle resolution for AI agents, and social media markets (Twitter, YouTube, DeFiLlama).

## When to Use This Skill

Use when the user wants to:
- **Create prediction markets** on Solana (V2 AMM, P2P, or custom oracle)
- **Trade on markets** (buy/sell YES/NO outcome tokens)
- **Settle markets** as an oracle after the trading period ends
- **Redeem winning positions** after settlement
- **Create social media markets** (Twitter engagement, YouTube views, DeFiLlama metrics)
- **Use custom tokens** as prediction market collateral (any SPL token including Token-2022)
- **Build autonomous AI agents** that create, trade, and resolve markets
- **Build info finance infrastructure** using market prices as probability signals

**Triggers**: `prediction market`, `betting`, `oracle`, `settlement`, `forecast`, `YES/NO`, `outcome token`, `market resolution`, `P2P bet`, `custom oracle`, `social media market`, `autonomous market`, `info finance`, `market creation`, `prediction`, `wager`, `binary outcome`

Do not use when:
- The task is generic Solana wallet operations (use solana-dev-skill instead)
- The task is token swaps/DEX trading without prediction markets (use jupiter-skill)
- The task is NFT-related (use metaplex-foundation/skill)
- The task is about other prediction market protocols (use their specific skill)

---

## Program IDs & Core Constants

| Item | Address | Notes |
|------|---------|-------|
| **PNP Program (Mainnet)** | `8PyE2dizL52ga7ytqLtqRyjwWp4yXEx8M5Z4BAHgHuTb` | Main prediction market program |
| **PNP Program (Devnet)** | `pnpkv2qnh4bfpGvTugGDSEhvZC7DP4pVxTuDykV3BGz` | Devnet testing program |
| **USDC Mint** | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` | Common collateral (6 decimals) |
| **USDT Mint** | `Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB` | Alternative stable (6 decimals) |
| **WSOL Mint** | `So11111111111111111111111111111111111111112` | Wrapped SOL (9 decimals) |

### Precision Reference

| Token Type | Decimals | Example |
|-----------|----------|---------|
| USDC / USDT | 6 | 1 USDC = `1_000_000n` |
| SOL (wrapped) | 9 | 1 SOL = `1_000_000_000n` |
| Decision tokens (YES/NO) | 6 | Minted per-market by the program |

```typescript
// Conversion helpers
const usdcToRaw = (amount: number) => BigInt(Math.floor(amount * 1_000_000));
const daysFromNow = (days: number) => BigInt(Math.floor(Date.now() / 1000) + days * 86400);

// Example
const liquidity = usdcToRaw(100);  // 100 USDC -> 100_000_000n
const endTime = daysFromNow(7);    // 7 days from now -> Unix timestamp as bigint
```

> [!IMPORTANT]
> **Collateral can be any SPL token or Token-2022 token.** Pass the token's mint address as `baseMint` or `collateralTokenMint`. Make sure to use the correct decimals for the chosen token (e.g., USDC/USDT = 6, SOL = 9). Common mints are listed in the table above for reference.

---

## Prerequisites

1. **Solana Wallet**: Base58-encoded private key with SOL for fees (~0.05 SOL minimum)
2. **Collateral Tokens**: Any SPL token (including Token-2022) for market liquidity — USDC, USDT, SOL, or any custom token
3. **RPC Endpoint**: Mainnet RPC URL (public or dedicated like Helius/QuickNode)

```bash
# Install dependencies
cd scripts && npm install

# Set environment variables
export PRIVATE_KEY=<base58_private_key>
export RPC_URL=https://api.mainnet-beta.solana.com  # or dedicated RPC
```

---

## Quick Start

```typescript
import { PNPClient } from 'pnp-sdk';
import { PublicKey } from '@solana/web3.js';

const client = new PNPClient(
  process.env.RPC_URL || 'https://api.mainnet-beta.solana.com',
  process.env.PRIVATE_KEY!  // Base58 string or Uint8Array
);

// Collateral can be any SPL token (including Token-2022) — use the mint address of your chosen token
const USDC = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');

// Create a prediction market
const result = await client.market.createMarket({
  question: 'Will Bitcoin reach $100K by end of 2025?',
  initialLiquidity: 1_000_000n,  // 1 USDC (6 decimals) — adjust decimals for your collateral token
  endTime: BigInt(Math.floor(Date.now() / 1000) + 30 * 24 * 60 * 60),
  baseMint: USDC,  // Any SPL or Token-2022 mint
});

console.log('Market created:', result.market.toBase58());
// Returns: { signature: string, market: PublicKey }
```

> [!TIP]
> Use `PNPClient.parseSecretKey(process.env.PRIVATE_KEY)` to handle both Base58 strings and JSON array formats automatically.

---

## Market Lifecycle & State Machine

Markets follow a strict state progression:

### V2 AMM Market (Standard)

```
CREATED ──────► ACTIVE ──────► ENDED ──────► RESOLVED ──────► CLAIMED
   │               │              │               │               │
   │          Trading live    No new trades   Oracle declares  Winners redeem
   │          Users buy/sell  allowed         YES/NO winner    collateral
   │          YES/NO tokens
   │
   └── initialLiquidity locked, PNP global oracle resolves
```

### Custom Oracle Market (Agent-Controlled)

```
CREATED ──► [15-MIN BUFFER] ──► ACTIVE ──► ENDED ──► RESOLVED ──► CLAIMED
   │               │                │          │           │           │
   │    setMarketResolvable(true)  Trade     Wait for   settleMarket() redeem
   │    MUST call within 15 min!   live      endTime    (oracle only)
   │
   └── Market starts frozen. If not activated within 15 minutes,
       it is PERMANENTLY FROZEN and cannot be recovered.
```

### State Transition Rules

| From | To | Method | Condition |
|------|-----|--------|-----------|
| CREATED | ACTIVE | `setMarketResolvable(market, true)` | Custom oracle only; must be within 15 min of creation |
| ACTIVE | ENDED | *(automatic)* | Unix timestamp reaches `endTime` |
| ENDED | RESOLVED | `settleMarket({market, yesWinner})` | Oracle-only; can only be called after `endTime` |
| RESOLVED | CLAIMED | `redeemPosition(marke
internet-courtSkill

Entry point for Internet Court — the trust layer for agent-to-agent commerce. Use whenever an agent needs to transact with another agent or a paid service, or a user mentions agent payments, paid APIs (HTTP 402/x402), wallet custody or trust concerns, spending mandates, delegated permissions (ERC-7710/7715), escrow, agent identity or reputation (ERC-8004), negotiation between agents (A2A), agent jobs (ERC-8183), machine payments (MPP, AP2), supervision of agent behavior, revocation, verification, or dispute resolution (GenLayer) — even if they never say "Internet Court". Routes to the vendored protocol skills and connector skills in this package.

genlayer-erc7710-connectorSkill

Connect GenLayer Intelligent Contract decisions to ERC-7710-style delegated authority. Use when an agent needs to design the interface, message schema, relayer/bridge path, EVM revocation controller, constraint updates, proof/finality assumptions, and failure handling that turn a GenLayer agent-performance review into ERC-7710 revocation or policy changes.

genlayer-intelligent-contractsSkill

Internet Court adapter for GenLayer Intelligent Contract supervision. Use to specify agent-performance rubrics, evidence schemas, decision outputs, and ERC-7710 connector expectations, while delegating actual GenLayer contract writing, linting, testing, deployment, and CLI interaction to the official GenLayer skills at https://skills.genlayer.com/.

x402-erc7710Skill

Design and implement demos combining x402 HTTP payments with ERC-7710 smart contract delegations and ERC-7715 wallet permission requests for subscriptions, bounded agent budgets, recurring spend, pay-per-use APIs, and agentic commerce.

0g-computeSkill

0G Compute Network guide for decentralized AI inference, fine-tuning, and GPU services. Covers chatbots, image generation, speech-to-text, SDK integration (0g-serving-broker), processResponse API, broker.inference methods, CLI commands (0g-compute-cli), and account management. Use this skill for any 0G compute, 0G AI, or decentralized GPU question.

altllm-portal-api-keysSkill

Use this skill when the user asks to list, create, inspect, update, disable, re-enable, or revoke AltLLM Portal API keys for external agents or applications. Do NOT use for wallet login, billing history, or payment links.

altllm-portal-authSkill

Use this skill when the user asks to log in or out with a wallet session, fetch a wallet sign-in challenge, verify an externally signed challenge, or troubleshoot AltLLM Portal wallet login for the local altllm CLI. Do NOT use for API key management, billing history, or payment links.

altllm-portal-billingSkill

Use this skill when the user asks to inspect AltLLM Portal balance, redeem a promo code, review billing transactions, or view usage analytics by period, model, or API key using the local altllm CLI. Do NOT use for API key lifecycle management or payment-link execution.