Use the TypeScript V2 trading defaults and keep protocol fees, builder attribution, and application fees distinct.
Install only the dependencies for the execution model you use. The injected
wallet/user-owned flow needs only:For optional zero-builder attribution backed by the signing wallet, see User-owned execution. For an injected-wallet application, follow Connect Wallet to order.
npm install polynode-sdk@^0.15.0 viem
For a server-signer trader, add the CLOB client and SQLite only when that
process uses them:
The optional official Polymarket relayer client currently brings legacy
Axios/ethers audit advisories into a full trading install. Polynode SDK 0.14.2
does not bundle that dependency tree: its only direct runtime dependency is
viem. Pin the relayer client to the SDK’s declared peer version, keep relayer
destinations fixed, and review upstream updates before changing that pin.
This version also trades Polymarket Protocol V2 markets, a separate and newer change from the V2 exchange default below, with the same calls and no config change. See Polymarket Protocol V2 markets.
Polymarket V2 is the default. You do not need to set exchangeVersion, but setting it explicitly can make a migration easier to review:
import { PolyNodeTrader } from 'polynode-sdk';const apiKey = process.env.POLYNODE_API_KEY;const privateKey = process.env.POLYGON_PRIVATE_KEY;if (!apiKey || !privateKey) throw new Error('Set the required environment variables');const trader = new PolyNodeTrader({ polynodeKey: apiKey, exchangeVersion: 'v2', builderCode: process.env.POLYMARKET_BUILDER_CODE,});const ready = await trader.ensureReady(privateKey);console.log('funder address', ready.funderAddress);
ensureReady() can deploy or approve wallet contracts and is state-changing for a new wallet. After the returned funder address is funded, trader.order(...) places a real order.V2 fees are applied by Polymarket at match time. Do not add legacy feeRateBps, nonce, or taker fields to a V2 signed order. A builder code attributes eligible volume; it does not itself charge an application fee. feeConfig is a separate, optional application-fee feature and remains disabled unless you configure it.
Read Trading and fees before running state-changing examples. It covers funding, cancellations, builder overrides, current V2 fee behavior, position operations, and cleanup.