Save a token ID from clobTokenIds — you’ll need it to place an order. The first ID is the Yes token, the second is the No token. See Fetching Markets for more strategies like fetching by slug, tag, or event.
2
Install the SDK
npm install @polymarket/clob-client-v2 viem
3
Set Up Your Client
Derive API credentials and initialize the trading client:
use std::str::FromStr;use polymarket_client_sdk_v2::POLYGON;use polymarket_client_sdk_v2::auth::{LocalSigner, Signer};use polymarket_client_sdk_v2::clob::{Client, Config};let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;let signer = LocalSigner::from_str(&private_key)? .with_chain_id(Some(POLYGON));// Derive API credentials and initialize trading client (L1 → L2 auth)// Signature type defaults to EOA (0)let client = Client::new("https://clob.polymarket.com", Config::default())? .authentication_builder(&signer) .authenticate() .await?;
This example uses an EOA wallet (signature type 0) — your wallet pays its
own gas. Proxy wallet users (types 1 and 2) can use Polymarket’s gasless
relayer instead. See Authentication for
details on signature types.
Before trading, your funder address needs pUSD (for buying outcome
tokens) and POL (for gas, if using EOA type 0).
4
Place an Order
Use the token_id from Step 1 to place a limit order:
from py_clob_client_v2 import OrderArgs, OrderType, PartialCreateOrderOptionsfrom py_clob_client_v2.order_builder.constants import BUY# Fetch market details to get tick size and neg riskmarket = client.get_market("YOUR_CONDITION_ID")tick_size = str(market["minimum_tick_size"]) # e.g., "0.01"neg_risk = market["neg_risk"] # e.g., Falseresponse = client.create_and_post_order( OrderArgs( token_id="YOUR_TOKEN_ID", # From Step 1 price=0.50, size=10, side=BUY, ), options=PartialCreateOrderOptions(tick_size=tick_size, neg_risk=neg_risk), order_type=OrderType.GTC,)print("Order ID:", response["orderID"])print("Status:", response["status"])
use polymarket_client_sdk_v2::clob::types::Side;use polymarket_client_sdk_v2::types::dec;// token_id is a U256 — parse from the string returned in Step 1let token_id = "YOUR_TOKEN_ID".parse()?;// The Rust SDK auto-fetches tick size, neg risk, and fee rate// No need to manually look them up — the order builder handles itlet order = client .limit_order() .token_id(token_id) .price(dec!(0.50)) .size(dec!(10)) .side(Side::Buy) .build() .await?;let signed_order = client.sign(&signer, order).await?;let response = client.post_order(signed_order).await?;println!("Order ID: {}", response.order_id);println!("Status: {:?}", response.status);