Skip to main content
Practical patterns for building on pnp-core. For per-method details see the API Reference.

Full market lifecycle

Create → take a position → settle → redeem, end to end:

Read-only client

Omit wallet for a client that only reads and derives — perfect for indexers, dashboards, and server-side rendering. Write methods throw if called.

Browser wallet adapter

Pass any wallet-adapter-compatible object (exposing publicKey + signTransaction). If it also exposes signMessage, off-chain flows like setSettlementCriteria work too.

Working with units

On-chain amounts are base units; UI values are human-readable. Convert explicitly.
Never mix UI and base units. Passing 100 (meaning 100 USDC) where base units are expected creates a market seeded with 0.0001 USDC.

Error handling

SDK writes are normal async calls — wrap them and surface program logs, which carry the on-chain revert reason.
Common reverts:

Security

Never hardcode or commit private keys. Load them from the environment or a keystore, and use a read-only client (PnpClient.mainnet() with no wallet) wherever you only need reads.
  • Keep custom-oracle / settler keys in a secrets manager — that key can settle markets.
  • Set minTokensOut on buy to bound slippage.
  • Use a private RPC endpoint for production throughput and reliability.

Runnable examples

The SDK repo ships a script for every market type in examples/create-markets/.

Create a Market

Every create path, with parameters.

Trading & Redemption

Buy, read odds, redeem.

FAQ

Mainnet and devnet, via PnpClient.mainnet() / PnpClient.devnet() (or cluster in the constructor). The program id is identical on both.
No. Construct the client without wallet for reads and PDA derivations. Only writes require a signer.
Those resolution kinds exist at the protocol level but have no dedicated SDK helper yet. Create a general market and attach settlement criteria.
AMM markets are create + read (readPrice / readMultiplier) in pnp-core today. The supported end-to-end trading flow is the parimutuel (p2p) path.
Both. pnp-core ships import (ESM), require (CJS), and TypeScript declarations.