New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@dschz/polymarket-clob-client

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dschz/polymarket-clob-client

Fork of Polymarket CLOB Client with optimized bundle size and enhanced Web3 integration

latest
Source
npmnpm
Version
0.4.4
Version published
Weekly downloads
17
-46.87%
Maintainers
1
Weekly downloads
 
Created
Source

Polymarket CLOB Client (@dschz)

License npm Bundle Size CI

Fork of Polymarket CLOB Client: GitHub / NPM

Typescript client for the Polymarket Central Limit Order Book (CLOB) API.

What's Different in This Fork

This fork provides several key improvements over the original:

  • Polymorphic Crypto APIs: Dynamically uses the appropriate cryptographic APIs based on the runtime environment (Node.js vs browser), ensuring optimal compatibility and performance.
  • Optimized Bundle Size: Significantly reduced bundle size for browser applications - approximately 50% smaller than the original package, making it ideal for web dApps with strict size constraints.
  • Enhanced Web3 Integration: Added utilities like createSignerForProvider that provide seamless integration with native EIP-1193 providers (MetaMask, WalletConnect, etc.) without requiring additional adapter libraries.

Installation

npm install @dschz/polymarket-clob-client
pnpm install @dschz/polymarket-clob-client
yarn install @dschz/polymarket-clob-client
bun install @dschz/polymarket-clob-client

Server Side (Node.js)

Node v18.0+ is required as this library uses native fetch APIs under the hood.

As of this writing (Nov. 2025), I would recommend using the latest Node v24.11.0+ LTS which will receive maintenance and updates until April 2028.

Web dApps / Vite Configuration

When bundling with Vite, you'll need to add Node.js polyfills for cryptographic operations and event handling. The library's underlying dependencies (ethers, crypto libraries) require buffer and events polyfills to function properly in browser environments. Install the required polyfills:

npm install buffer events
pnpm install buffer events
yarn install buffer events
bun install buffer events

Then update your vite.config.ts to help the dev server reference the buffer polyfill:

import { defineConfig } from "vite";

export default defineConfig({
  // When running your Vite dev server, you may see browser warnings regarding Buffer.
  // The optimizeDeps and resolve aliases for buffer should take care of them
  optimizeDeps: {
    include: ["buffer"],
  },
  resolve: {
    conditions: ["development", "browser"],
    alias: {
      buffer: "buffer/",
      "node:buffer": "buffer/",
    },
  },
});

Usage

💡 When creating a ClobClient instance, the following defaults are used for unspecified parameters:

  • host: "https://clob.polymarket.com" (Polymarket production API)
  • chainId: 137 (Polygon mainnet)
  • signatureType: 0 (EOA - Externally Owned Account)
  • funderAddress: Defaults to the signer address when not provided

This means you can create a minimal, read-only client with just new ClobClient() which will hit Polygon mainnet. If you want to place trades on mainnet, then you need to configure both signer and creds via new ClobClient({ signer, creds }) which you can see the examples configure below.

Browser Environment with Wallet Providers

The CLOB client supports various wallet providers in web browsers. Use the createSignerForProvider utility to create a signer from any EIP-1193 compatible provider:

import {
  ClobClient,
  createSignerForProvider,
  OrderType,
  Side,
} from "@dschz/polymarket-clob-client";

// Example 1: MetaMask
if (window.ethereum) {
  // Pass any object conforming to the EIP-1193 provider spec
  const signer = createSignerForProvider(window.ethereum);
  // Get API key derived from signer for Polygon mainnet
  const creds = await new ClobClient({ signer }).createOrDeriveApiKey();
  // Defaults to Polygon mainnet, signer funderAddress, signature type 0 for EOA
  const clobClient = new ClobClient({ signer, creds });

  // Place an order
  const order = await clobClient.createAndPostOrder(
    {
      tokenID: "your-token-id",
      price: 0.6,
      side: Side.BUY,
      size: 10,
    },
    { tickSize: "0.01", negRisk: false },
    OrderType.GTC,
  );
}

With Privy

Works seamlessly with Privy embedded wallets:

import { usePrivy } from "@privy-io/react-auth";
import { ClobClient, createSignerForProvider } from "@dschz/polymarket-clob-client";

function TradingComponent() {
  const { authenticated, getEthereumProvider } = usePrivy();

  if (authenticated) {
    const provider = await getEthereumProvider();
    const signer = createSignerForProvider(provider);

    const creds = await new ClobClient({ signer }).createOrDeriveApiKey();
    const clobClient = new ClobClient({ signer, creds });

    // Use clobClient for trading...
  }
}

Node.js Environment

For server-side or Node.js applications with private keys:

import { ClobClient, OrderType, Side } from "@dschz/polymarket-clob-client";
import { Wallet } from "@ethersproject/wallet";

const funder = "0x..."; // Your Polymarket Profile Address
const signer = new Wallet("your-private-key"); // Your private key

const creds = await new ClobClient({ signer }).createOrDeriveApiKey();
const clobClient = new ClobClient({
  signer,
  creds,
  signatureType: 1,
  funderAddress: funder,
});

const order = await clobClient.createAndPostOrder(
  {
    tokenID: "your-token-id",
    price: 0.01,
    side: Side.BUY,
    size: 5,
  },
  { tickSize: "0.001", negRisk: false },
  OrderType.GTC,
);

Signature Types

  • 0: Browser Wallet (MetaMask, Coinbase Wallet, WalletConnect, etc.)
  • 1: Magic/Email Login or Server-side private key signing

See examples for more information

Keywords

blockchain

FAQs

Package last updated on 01 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts