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

sdk-use

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sdk-use

This directory contains SDK usage examples for `@parthsoni07/pnp-sdk-v2`. Each file demonstrates how to use the SDK to perform various operations that were previously done via scripts.

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

SDK Usage Examples

This directory contains SDK usage examples for @parthsoni07/pnp-sdk-v2. Each file demonstrates how to use the SDK to perform various operations that were previously done via scripts.

Setup

  • Install dependencies:
npm install
  • Set up environment variables (create a .env file in the root directory):
PNP_RPC_URL=https://api.mainnet-beta.solana.com
HARDCODED_PRIVATE_KEY=your_private_key_here

Note: All examples load the .env file from the root directory (parent of sdk-use), not from sdk-use itself.

Usage

Each example file can be run directly with tsx or ts-node:

# Example: Create a P2P market
tsx createP2PQuickstart.ts

# Example: Trade on V3 market
tsx trade_v3.ts

# Example: Get market info
tsx market-info.ts

Available Examples

These examples demonstrate the new functionality and logic enhancements added in v2 branch (not just logging improvements).

P2P Market Creation (NEW in v2)

  • createP2PQuickstart.ts - Create a generic P2P market with simple parameters
  • createP2PTwitter.ts - Create a Twitter-linked P2P market
  • createP2PYoutube.ts - Create a YouTube-linked P2P market
  • createP2PandTrade.ts - Create a P2P market and trade on it
  • p2pRefund.ts - Claim P2P market creator refund

V3 Market Operations (NEW in v2)

  • trade_v3.ts - Trade on V3 markets
  • redeem_v3_position.ts - Redeem winning positions from resolved V3 markets
  • v3_market_info.ts - Get information about V3 P2P markets
  • list_v3_markets.ts - List all V3 market addresses
  • fetch_my_v3_markets.ts - Fetch V3 markets where you have positions
  • fetch_resolved_markets.ts - Fetch all resolved V3 markets

Market Creation (Enhanced in v2)

  • createMarket.ts - Create a standard market (with balance checking logic)
  • createMarketV3.ts - Create a V3 market (P2P market creation)
  • createMarketV3_oracle.ts - Create a V3 market with oracle
  • createMarketAndRefund.ts - Create market and claim refund if not resolvable
  • createMarketAndTrade.ts - Create market and trade on it

Market Information (NEW in v2)

  • market-info.ts - Get comprehensive market information (enhanced)
  • v2_market_info.ts - Get V2 market information
  • v3_market_info.ts - Get V3 market information
  • winningToken.ts - Get winning token for resolved markets (V2 or V3)

Key Differences from Scripts

  • Import from npm package: All examples import from @parthsoni07/pnp-sdk-v2 instead of local paths
  • Environment variables: Use .env file with dotenv/config for configuration
  • ESM modules: All files use ES modules (import/export)
  • Simplified structure: Focus on SDK usage rather than script execution

Note

Only files with actual logic enhancements or new functionality in v2 are included here. Files that only had logging improvements, type safety changes, or minor refactoring have been excluded.

Notes

  • All examples output structured JSON results between === RESULT === markers
  • Set VERBOSE=1 environment variable for detailed output
  • Private key (HARDCODED_PRIVATE_KEY) can be provided as JSON array string or base58 string in the root .env file
  • Most read-only operations don't require a private key

FAQs

Package last updated on 19 Dec 2025

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