npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dschz/polymarket-clob-client

v0.4.4

Published

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

Downloads

175

Readme

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