Skip to content

Unable to post orders #271

@ctwizz1e

Description

@ctwizz1e

Unable to post order using clob-client.

Minimal POC to reproduce problem:

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

const funder = ""; // address where USDC was sent
const KEY = "" // from https://reveal.magic.link/polymarket 

const HOST = "https://clob.polymarket.com";
const CHAIN_ID = 137; // Polygon mainnet
const signatureType = 1;

const signer = new Wallet(KEY);
const c1 = new ClobClient(HOST, CHAIN_ID, signer);
const creds = await c1.createApiKey(Math.floor(Date.now() / 1000)); // slowly incrementing nonce for repeated runs

const client = new ClobClient(
  HOST,
  CHAIN_ID,
  signer,
  creds,
  signatureType,
  funder
);

const order = await client.createAndPostOrder(
  {
    tokenID: "63313490343742182398964413712758754063105691661002540468781137134481524624739", price: 0.50, size: 10, side: "BUY" as any,
    feeRateBps: 1
  },
  { negRisk: false },
  OrderType.GTC
);

The error message I get (with ID's and api keys removed) is:

[CLOB Client] request error {"status":401,"statusText":"Unauthorized","data":{"error":"Unauthorized/Invalid api key"},"config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"adapter":["xhr","http","fetch"],"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{},"headers":{"Accept":"*/*","Content-Type":"application/json","POLY_ADDRESS":"xxx","POLY_SIGNATURE":"xxx","POLY_TIMESTAMP":"1769388792","POLY_API_KEY":"xxx","POLY_PASSPHRASE":"xxx","User-Agent":"@polymarket/clob-client","Connection":"keep-alive","Content-Length":"654","Accept-Encoding":"gzip, compress, deflate, br"},"method":"post","url":"https://clob.polymarket.com/order","data":"{\"deferExec\":false,\"order\":{\"salt\":xxx,\"maker\":\"xxx\",\"signer\":\"xxx\",\"taker\":\"0x0000000000000000000000000000000000000000\",\"tokenId\":\"63313490343742182398964413712758754063105691661002540468781137134481524624739\",\"makerAmount\":\"5000000\",\"takerAmount\":\"10000000\",\"side\":\"BUY\",\"expiration\":\"0\",\"nonce\":\"0\",\"feeRateBps\":\"0\",\"signatureType\":0,\"signature\":\"xxx\"},\"owner\":\"xxx\",\"orderType\":\"GTC\",\"postOnly\":false}","params":{},"allowAbsoluteUrls":true}}

I've tried every combination of everything I've found online. I signed up with a magic email, but I looked at trying the other signature types as well. I saw one place that the client used to generate creds needed the signature type but that didn't work either. I've already manually traded on the account so I know it's been allowed to trade and it has money in it. I saw the other issue about intercepting axios to set the api key but that didn't work for me. I tried downgrading my clob-client package and that didn't work for me. I can use the client to view open orders and it works fine so I don't have any typos on the keys. I'm pretty much out of ideas, so any help here is appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions