Skip to main content
This guide walks you through placing an order on Polymarket end-to-end.
1

Install the SDK

npm install @polymarket/clob-client ethers@5
2

Set Up Your Client

Derive your API credentials and initialize the trading client. This example uses an EOA wallet (type 0) — your wallet pays its own gas and acts as the funder:
import { ClobClient } from "@polymarket/clob-client";
import { Wallet } from "ethers"; // v5.8.0

const HOST = "https://clob.polymarket.com";
const CHAIN_ID = 137; // Polygon mainnet
const signer = new Wallet(process.env.PRIVATE_KEY);

// Derive API credentials
const tempClient = new ClobClient(HOST, CHAIN_ID, signer);
const apiCreds = await tempClient.createOrDeriveApiKey();

// Initialize trading client
const client = new ClobClient(
  HOST,
  CHAIN_ID,
  signer,
  apiCreds,
  0, // EOA
  signer.address,
);
If you have a Polymarket.com account, your funds are in a proxy wallet — use signature type 1 or 2 instead. See Signature Types for details.
Before trading, your funder address needs USDC.e (for buying outcome tokens) and POL (for gas, if using EOA type 0). Proxy wallet users (types 1 and 2) can use Polymarket’s gasless relayer instead.
3

Place an Order

Get a token ID from the Markets API, then create and submit your order:
import { Side, OrderType } from "@polymarket/clob-client";

const response = await client.createAndPostOrder(
  {
    tokenID: "YOUR_TOKEN_ID",
    price: 0.5,
    size: 10,
    side: Side.BUY,
  },
  {
    tickSize: "0.01",
    negRisk: false, // Set to true for multi-outcome markets
  },
  OrderType.GTC,
);

console.log("Order ID:", response.orderID);
console.log("Status:", response.status);
Look up a market’s tickSize and negRisk values using the SDK’s getTickSize() and getNegRisk() methods, or from the market object returned by the API.
4

Check Your Orders

// View all open orders
const openOrders = await client.getOpenOrders();
console.log(`You have ${openOrders.length} open orders`);

// View your trade history
const trades = await client.getTrades();
console.log(`You've made ${trades.length} trades`);

// Cancel an order
await client.cancelOrder(response.orderID);

Troubleshooting

Wrong private key, signature type, or funder address for the derived API credentials.
  • Check that signatureType matches your account type (0, 1, or 2)
  • Ensure funder is correct for your wallet type
  • Re-derive credentials with createOrDeriveApiKey() if unsure
Your funder address doesn’t have enough tokens:
  • BUY orders: need USDC.e in your funder address
  • SELL orders: need outcome tokens in your funder address
  • Ensure you have more USDC.e than what’s committed in open orders
You need to approve the Exchange contract to spend your tokens. This is typically done through the Polymarket UI on your first trade, or using the CTF contract’s setApprovalForAll() method.
Your funder address is the wallet where your funds are held:
  • EOA (type 0): Your wallet address directly
  • Proxy wallet (type 1 or 2): Go to polymarket.com/settings and look for the wallet address in the profile dropdown
If the proxy wallet doesn’t exist, log into Polymarket.com first (it’s deployed on first login).
You’re trying to place a trade from a restricted region. See Geographic Restrictions for details.

Next Steps