Overview
The trading module lets you place and manage orders on Polymarket. One function call handles wallet setup, credential creation, approvals, and order placement. You don’t need to understand Polymarket’s wallet types, contract addresses, or signing protocols.Your project must use ESM imports (
import syntax). Add "type": "module" to your package.json, or use .mjs file extensions.Quick Start
Pick the path that matches your situation.I’m building a backend service (private keys on your server)
Generate wallets, manage them yourself. This is the simplest path.ensureReady() is idempotent. Call it every time your service starts. If the wallet is already set up, it returns instantly from the local database.
I’m building a platform with Privy (server wallets for each user)
UsecreatePrivySigner to trade with Privy-managed wallets. Each user gets their own wallet without touching private keys.
- Create a Privy app at dashboard.privy.io
- Enable Server wallets under Wallet infrastructure
- Generate an Authorization keypair (same section) — this is
PRIVY_AUTHORIZATION_KEY - Install:
npm install @privy-io/server-auth(the SDK imports it automatically viacreatePrivyClient)
I already have a Polymarket account (exported key or existing credentials)
If you export your private key from Polymarket, the SDK auto-detects your wallet type.Where to Send USDC.e
AfterensureReady(), send USDC.e to status.funderAddress. This is the address that holds your trading balance.
| Wallet type | funderAddress is… |
|---|---|
| Safe (default) | The Safe contract address (different from your private key’s address) |
| EOA | The wallet address itself |
Finding Markets
You need atokenId to place orders. Here’s how to find one:
GET /v1/events/search?q=bitcoin&limit=5 or GET /v1/crypto/active for live crypto markets.
Configuration
Builder Attribution (Your Own Credentials)
By default, orders placed through polynode are attributed to polynode’s builder profile on Polymarket. If you’re running a platform and want volume credited to your own builder account, pass your credentials inbuilderCredentials.
- Go to polymarket.com/settings?tab=builder and create a builder profile
- Generate API credentials (key, secret, passphrase)
- Pass them in
builderCredentialswhen constructing the trader
builderCredentials is set:
- All orders are attributed to your builder profile on the Builder Leaderboard
- Gasless Safe deployments and approvals use your builder account
- polynode never stores your builder credentials. They’re sent per-request and used only for HMAC signing.
builderCredentials is omitted, polynode’s default builder credentials are used. Your orders still go through, you just don’t get the builder attribution on your own profile.
API Reference
PolyNodeTrader.generateWallet()
Static async method. Generates a fresh wallet. You must await this call.
ensureReady(signer, opts?)
One-call onboarding. Detects wallet type, deploys contracts if needed, sets all approvals, creates CLOB credentials.
Signer types accepted:
string— hex private key (most common)createPrivySigner(...)— Privy server wallet- ethers v5/v6 Signer
- viem WalletClient
ReadyStatus with funderAddress (where to send USDC.e), signatureType, approvalsSet, credentials, and actions (what it did).
Calling it again on a ready wallet is instant (loads from local DB).
order(params)
Place an order on Polymarket.
cancelOrder(orderId) / cancelAll(market?)
Cancel a specific order or all orders.
split(params)
Split USDC into YES + NO outcome tokens. Gasless for Safe wallets. Auto-detects neg-risk vs standard markets.
merge(params)
Merge YES + NO outcome tokens back into USDC. Gasless for Safe wallets.
convert(params)
Convert NO positions on selected outcomes into USDC + YES on complementary outcomes. Only works on neg-risk multi-outcome markets. Gasless for Safe wallets.
checkBalance(wallet?)
Returns USDC.e and MATIC balance for the funder address.
checkApprovals(wallet?)
Check if all 6 required token approvals are set on-chain.
getOpenOrders(params?)
Fetch open orders from the CLOB. Filters: market, assetId.
getOrderHistory(params?)
Query local order history from SQLite. Filters: limit, offset, tokenId, side.
linkCredentials(opts) / linkWallet(signer)
Import existing credentials or link a wallet manually.
exportWallet(wallet?) / exportAll() / importWallet(exported)
Export and import wallet state for backup. Private keys are never included.
unlinkWallet(address?) / getLinkedWallets()
Remove or list stored wallets.
close()
Close the SQLite connection. Call this when shutting down.
How It Works
- SDK signs the order locally (EIP-712)
- SDK sends to polynode’s relay at
trade.polynode.dev - Relay adds builder attribution and forwards to Polymarket’s CLOB
- Response returned to SDK, logged in local SQLite
fallbackDirect is true, orders go directly to Polymarket. Your trading never stops.
Credential Custody
Credentials are stored in a local SQLite database. The SDK never sends your private key or CLOB credentials to polynode’s servers. Back up withexportWallet().

