Skip to main content

Overview

Builder attribution in V2 is handled natively through the order struct — you attach your builder code (a bytes32 identifier from your Builder Profile) to every order you submit. No separate client configuration is required.
import { ClobClient } from "@polymarket/clob-client-v2";

const client = new ClobClient({
  host: "https://api.copilot.markets/clob",
  chain: 137,
  signer,
  creds: apiCreds,
  signatureType,
  funderAddress,
});

// Attach your builder code on every order
const response = await client.createAndPostOrder(
  {
    tokenID: "0x...",
    price: 0.55,
    size: 100,
    side: Side.BUY,
    builderCode: process.env.POLY_BUILDER_CODE!,
  },
  { tickSize: "0.01", negRisk: false },
);
See Order Attribution for the full attribution flow.

Methods


getOrder

Get details for a specific order by ID.
Signature
async getOrder(orderID: string): Promise<OpenOrder>
const order = await client.getOrder("0xb816482a...");
console.log(order);

getOpenOrders

Get all open orders attributed to your builder code.
Signature
async getOpenOrders(
  params?: OpenOrderParams,
  only_first_page?: boolean,
): Promise<OpenOrder[]>
Params
id
string
Optional. Filter by order ID.
market
string
Optional. Filter by market condition ID.
asset_id
string
Optional. Filter by token ID.
TypeScript
// All open orders for this builder
const orders = await client.getOpenOrders();

// Filtered by market
const marketOrders = await client.getOpenOrders({
  market: "0xbd31dc8a...",
});

getBuilderTrades

Retrieves all trades attributed to your builder code. Use this to track which trades were routed through your platform.
Signature
async getBuilderTrades(
  params?: TradeParams,
): Promise<BuilderTradesPaginatedResponse>
Params (TradeParams)
id
string
Optional. Filter trades by trade ID.
maker_address
string
Optional. Filter trades by maker address.
market
string
Optional. Filter trades by market condition ID.
asset_id
string
Optional. Filter trades by asset (token) ID.
before
string
Optional. Return trades created before this cursor value.
after
string
Optional. Return trades created after this cursor value.
Response (BuilderTradesPaginatedResponse)
trades
BuilderTrade[]
Array of trades attributed to the builder account.
next_cursor
string
Cursor string for fetching the next page of results.
limit
number
Maximum number of trades returned per page.
count
number
Total number of trades returned in this response.
BuilderTrade fields
id
string
Unique identifier for the trade.
tradeType
string
Type of the trade.
takerOrderHash
string
Hash of the taker order associated with this trade.
builder
string
Builder code attributed to this trade.
market
string
Condition ID of the market this trade belongs to.
assetId
string
Token ID of the asset traded.
side
string
Side of the trade (e.g. BUY or SELL).
size
string
Size of the trade in shares.
sizeUsdc
string
Size of the trade denominated in USDC.
price
string
Price at which the trade was executed.
status
string
Current status of the trade.
outcome
string
Outcome label associated with the traded asset.
outcomeIndex
number
Index of the outcome within the market.
owner
string
Address of the order owner (taker).
maker
string
Address of the maker in the trade.
transactionHash
string
On-chain transaction hash for the trade.
matchTime
string
Timestamp when the trade was matched.
bucketIndex
number
Bucket index used for trade grouping.
fee
string
Fee charged for the trade in shares.
feeUsdc
string
Fee charged for the trade denominated in USDC.
err_msg
string | null
Optional. Error message if the trade encountered an issue, otherwise null.
createdAt
string | null
Timestamp when the trade record was created, or null if unavailable.
updatedAt
string | null
Timestamp when the trade record was last updated, or null if unavailable.

See Also

Builders Program

Learn about the Builders Program and its benefits.

Order Attribution

Attach your builder code to orders for volume credit.

L2 Methods

Place and manage orders with API credentials.

Gasless Transactions

Execute onchain operations without paying gas.