FAQ

Frequently asked questions about the TypeScript SDK (@opinion-labs/opinion-clob-sdk v0.5.2).


Installation and Setup

chevron-rightHow do I install the SDK?hashtag
npm install @opinion-labs/opinion-clob-sdk

The package is published on npm as @opinion-labs/opinion-clob-sdk.

chevron-rightWhat are the minimum requirements?hashtag
  • Node.js: 18 or later

  • TypeScript: 5.3 or later (if using TypeScript)

  • The SDK is an ESM package and requires an ESM-compatible project setup.

chevron-rightHow do I use the SDK in a CommonJS project?hashtag

The SDK is published as ESM. If your project uses CommonJS (require), use dynamic import():

async function main() {
  const { Client, CHAIN_ID_BNB_MAINNET, DEFAULT_API_HOST } = await import(
    '@opinion-labs/opinion-clob-sdk'
  );

  const client = new Client({
    host: DEFAULT_API_HOST,
    apiKey: 'YOUR_API_KEY',
    chainId: CHAIN_ID_BNB_MAINNET,
    rpcUrl: 'YOUR_RPC_URL',
    privateKey: '0xYOUR_PRIVATE_KEY',
    multiSigAddress: '0xYOUR_MULTI_SIG_ADDRESS',
  });
}

main();

Alternatively, add "type": "module" to your package.json to enable ESM.

chevron-rightWhat imports do I need?hashtag
// Main client
import { Client, CHAIN_ID_BNB_MAINNET, DEFAULT_API_HOST } from '@opinion-labs/opinion-clob-sdk';

// Enums
import {
  TopicType,
  TopicStatus,
  TopicStatusFilter,
  TopicSortType,
  OrderSide,
  OrderType,
} from '@opinion-labs/opinion-clob-sdk';

// Types
import type { PlaceOrderDataInput } from '@opinion-labs/opinion-clob-sdk';

// Error classes
import {
  InvalidParamError,
  OpenApiError,
  BalanceNotEnough,
  NoPositionsToRedeem,
  InsufficientGasBalance,
  ValidationException,
} from '@opinion-labs/opinion-clob-sdk';

// Builder mode (optional)
import { BuilderClient, UserClient } from '@opinion-labs/opinion-clob-sdk';

Configuration

chevron-rightWhich chain IDs are supported?hashtag

Currently only BNB Chain mainnet (chain ID 56) is supported. Use the constant CHAIN_ID_BNB_MAINNET:

chevron-rightWhat is the difference between the private key and the multi-sig address?hashtag
  • Private Key (privateKey): The key of your login wallet (EOA). Used for signing orders and transactions. This wallet needs BNB for gas fees on blockchain operations.

  • Multi-Sig Address (multiSigAddress): Your asset wallet (Gnosis Safe). This is where your trading funds are held. It is the address shown in "My Portfolio" on the platform.

The signer (login wallet) authorizes trades on behalf of the multi-sig (asset wallet).

chevron-rightHow do I get an API key?hashtag

Contact the Opinion Labs team to obtain your API key for SDK access. The API key is passed in the apikey HTTP header for all API requests.

chevron-rightHow do I find my asset wallet (multi-sig) address?hashtag
  1. Click the Add Fund button on the navigation bar.

  2. Click Create Your Asset Wallet if you do not have one.

  3. Wait a few minutes and reopen the popup.

  4. Copy the address displayed.

chevron-rightHow do I configure a proxy?hashtag

Pass the proxyUrl option during client initialization:

The proxy applies to both HTTP API calls and WebSocket connections.

chevron-rightCan I override the default contract addresses?hashtag

Yes, but only do so if instructed by the Opinion Labs team:


Trading

chevron-rightWhat is the difference between market orders and limit orders?hashtag
  • Market order (OrderType.MARKET_ORDER): Executes immediately at the best available price. You specify how much to spend (buy) or how many shares to sell. Price is ignored.

  • Limit order (OrderType.LIMIT_ORDER): Executes at your specified price or better. If the market price does not reach your limit, the order remains open until filled, canceled, or expired.

chevron-rightHow do I specify order amounts?hashtag

There are two ways:

  • By quote token (makerAmountInQuoteToken): Specify how much USDC to spend. Example: "100" means 100 USDC.

  • By shares (makerAmountInBaseToken): Specify how many outcome tokens (shares). Example: "50" means 50 Yes tokens.

Rules:

Order Type
Side
Allowed Amount Field

Market

Buy

makerAmountInQuoteToken only

Market

Sell

makerAmountInBaseToken only

Limit

Buy

Either

Limit

Sell

Either

chevron-rightDo I need to call enableTrading() before every order?hashtag

No. You only need to call enableTrading() once per trading account. After that, your orders can be filled on-chain.

Alternatively, pass checkApproval: true to placeOrder(), which will check and enable trading if needed. However, for performance, it is better to call enableTrading() once at startup.

chevron-rightHow do I cancel orders?hashtag
chevron-rightWhat are the order status codes?hashtag
Status
Meaning

1

Pending (open)

2

Filled

3

Canceled

4

Expired

5

Failed

6

On-chain failed


Smart Contracts

chevron-rightWhich operations require gas (BNB)?hashtag
Operation
Gas Required
Description

enableTrading()

Yes

Approve token spending on-chain

split()

Yes

Convert collateral to outcome tokens

merge()

Yes

Convert outcome tokens back to collateral

redeem()

Yes

Claim winnings from resolved markets

placeOrder()

No

Off-chain signed order

cancelOrder()

No

Off-chain cancellation

getMarkets()

No

API call

All get* methods

No

API calls

chevron-rightWhat is the split/merge/redeem workflow?hashtag
  1. Split: Deposit USDC into a market to receive equal amounts of Yes and No tokens.

  2. Trade: Buy or sell outcome tokens on the order book.

  3. Merge: Convert equal amounts of Yes and No tokens back to USDC (useful to exit both sides).

  4. Redeem: After market resolution, exchange winning tokens for USDC.

chevron-rightWhat market statuses allow split and merge?hashtag

Both split() and merge() require the market to be in one of these statuses:

  • ACTIVATED (2)

  • RESOLVING (3)

  • RESOLVED (4)

chevron-rightWhat market status is required for redeem?hashtag

Only RESOLVED (4). The market must have a final outcome before you can redeem.


Errors

chevron-rightWhy do I get "Invalid parameter" errors?hashtag

Common causes:

  • page is less than 1.

  • limit is less than 1 or greater than 20.

  • marketId is 0 or negative.

  • tokenId is an empty string.

  • orderId is an empty string.

  • Using makerAmountInBaseToken for a market buy order (not allowed).

  • Using makerAmountInQuoteToken for a market sell order (not allowed).

  • Amount is less than 1 (minimum order size).

chevron-rightWhat does "Cannot split/merge/redeem on different chain" mean?hashtag

The market you are trying to interact with belongs to a different blockchain than your client is configured for. Ensure chainId is set to 56 and the market is on BNB Chain.

chevron-rightWhat does "Cannot redeem on non-resolved market" mean?hashtag

You can only redeem from markets that have been resolved (status = 4). Check the market status first:

chevron-rightHow do I handle network errors?hashtag

Wrap your calls in try/catch and check for OpenApiError:


Data and Precision

chevron-rightHow are prices represented?hashtag

Prices are strings representing a value between 0 and 1. For example, "0.55" means 55 cents per outcome token. A price of "1" means the outcome is considered certain.

chevron-rightHow are amounts represented?hashtag
  • API responses: Amounts are returned as strings with full decimal precision (e.g., "887306.479964285714285714").

  • placeOrder input: Use human-readable strings (e.g., "100" for 100 USDC).

  • split/merge input: Use bigint in wei (e.g., BigInt(100 * 10**6) for 100 USDC with 6 decimals).

chevron-rightWhat decimal precision should I use for split/merge amounts?hashtag

It depends on the collateral token's decimals. Check with getQuoteTokens():

chevron-rightWhy are there floating-point precision differences in prices?hashtag

The SDK uses string-based arithmetic internally to minimize floating-point issues. Prices and amounts in API responses are always strings. When performing your own calculations, avoid native floating-point math; use a library like decimal.js for precise calculations.


Support

chevron-rightWhere can I find more documentation?hashtag
chevron-rightHow do I report a bug?hashtag
  • GitHub Issues: Open an issue on the SDK repository with:

    • SDK version (npm list @opinion-labs/opinion-clob-sdk)

    • Node.js version (node --version)

    • Full error message and stack trace

    • Minimal code to reproduce the issue

chevron-rightIs there a Python SDK available?hashtag

Yes. The Python SDK (opinion_clob_sdk) provides equivalent functionality. See the Python SDK documentation for details.