internet-court/internet-court-skill / vendored/pnp/pnp-solana
pnp-markets-solana
FlaggedCreate, 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).
| File | Kind | Size |
|---|---|---|
| .gitignore | other | 272 B |
| LICENSE | other | 1.6 KB |
| README.md | markdown | 3.5 KB |
| SKILL.md | skill md | 29.5 KB |
| package-lock.json | manifest | 69.8 KB |
| package.json | manifest | 52 B |
| references/api-reference.md | markdown | 15.7 KB |
| references/examples.md | markdown | 6.3 KB |
| references/program-addresses.md | markdown | 7.4 KB |
| references/types-and-precision.md | markdown | 7.3 KB |
| references/use-cases.md | markdown | 4.1 KB |
| scripts/create-market-custom.ts | script | 1.5 KB |
| scripts/create-market-p2p.ts | script | 4.0 KB |
| scripts/create-market-x.ts | script | 1.5 KB |
| scripts/create-market-yt.ts | script | 1.4 KB |
| scripts/create-market.ts | script | 1.4 KB |
| scripts/market-data.ts | script | 3.5 KB |
| scripts/package.json | manifest | 549 B |
| scripts/redeem.ts | script | 3.0 KB |
| scripts/settle.ts | script | 5.5 KB |
| scripts/trade.ts | script | 5.8 KB |
| scripts/tsconfig.json | config | 346 B |
scripts/create-market-p2p.ts
View on GitHub/**
* Mainnet Script: Create V3 P2P Market
*
* Creates a peer-to-peer prediction market on Solana mainnet.
* The creator takes one side (YES or NO) and other users can take the opposite.
*
* Usage:
* tsx scripts/create-market-p2p.ts
*
* Environment:
* PRIVATE_KEY - Your wallet private key (base58)
* RPC_URL - (Optional) Solana RPC endpoint
*/
import 'dotenv/config';
import { PublicKey, Connection } from '@solana/web3.js';
import { PNPClient } from 'pnp-sdk';
// =====================================================
// ========== MAINNET CONFIGURATION ====================
// =====================================================
const RPC_URL = process.env.RPC_URL || 'https://api.mainnet-beta.solana.com';
const PRIVATE_KEY = process.env.PRIVATE_KEY;
if (!PRIVATE_KEY) {
console.error('β PRIVATE_KEY environment variable is required.');
process.exit(1);
}
// Collateral can be any SPL token or Token-2022 token.
// Set COLLATERAL_MINT env var to use a different token, or defaults to USDC as an example.
const USDC_MINT = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
const COLLATERAL_MINT = new PublicKey(process.env.COLLATERAL_MINT || USDC_MINT);
// Market parameters
const QUESTION = process.env.QUESTION || 'Will this event happen by the deadline?';
const SIDE: 'yes' | 'no' = (process.env.SIDE || 'yes').toLowerCase() === 'no' ? 'no' : 'yes';
const INITIAL_AMOUNT = BigInt(process.env.AMOUNT || '1000000'); // 1 USDC (6 decimals)
const CREATOR_SIDE_CAP = INITIAL_AMOUNT * 5n; // 5x multiplier
const DAYS_UNTIL_END = Number(process.env.DAYS_UNTIL_END || '7');
const END_TIME = BigInt(Math.floor(Date.now() / 1000) + DAYS_UNTIL_END * 24 * 60 * 60);
async function main() {
console.log('\nπ― PNP SDK - Mainnet P2P Market Creation\n');
// Initialize client
const secretKey = PNPClient.parseSecretKey(PRIVATE_KEY!);
const client = new PNPClient(RPC_URL, secretKey);
const walletAddress = client.signer!.publicKey;
console.log('π Configuration:');
console.log(` β’ Wallet: ${walletAddress.toBase58()}`);
console.log(` β’ Question: ${QUESTION}`);
console.log(` β’ Side: ${SIDE.toUpperCase()}`);
console.log(` β’ Amount: ${INITIAL_AMOUNT.toString()} (raw units)`);
console.log(` β’ Collateral: ${COLLATERAL_MINT.toBase58()}`);
console.log(` β’ End Time: ${new Date(Number(END_TIME) * 1000).toISOString()}`);
console.log('');
// Check balance
const connection = new Connection(RPC_URL);
const balance = await connection.getBalance(walletAddress);
console.log(`π° SOL Balance: ${balance / 1e9} SOL`);
if (balance < 10_000_000) { // 0.01 SOL minimum
console.error('β Insufficient SOL for transaction fees.');
process.exit(1);
}
try {
console.log('\nβ³ Creating P2P market...\n');
const result = await client.createP2PMarketGeneral({
question: QUESTION,
initialAmount: INITIAL_AMOUNT,
side: SIDE,
creatorSideCap: CREATOR_SIDE_CAP,
endTime: END_TIME,
collateralTokenMint: COLLATERAL_MINT,
});
console.log('β
P2P Market Created Successfully!\n');
console.log('π Market Details:');
console.log(` β’ Market: ${result.market}`);
console.log(` β’ Signature: ${result.signature}`);
console.log(` β’ Your Side: ${SIDE.toUpperCase()}`);
console.log(` β’ Explorer: https://solscan.io/tx/${result.signature}`);
console.log('\nπ JSON Output:');
console.log(JSON.stringify({
market: result.market,
signature: result.signature,
side: SIDE,
network: 'mainnet',
}, null, 2));
} catch (error: any) {
console.error('β Market creation failed:', error.message);
if (error.logs) {
console.error('\nTransaction logs:');
error.logs.forEach((log: string) => console.error(` ${log}`));
}
process.exit(1);
}
}
main().catch(console.error);Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path β even casually (like "the xlsx in my downloads") β and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |