Configuration
This guide covers how to configure the Opinion CLOB TypeScript SDK for different environments and use cases.
Client Configuration
The Client class accepts a configuration object during initialization:
import { Client, CHAIN_ID_BNB_MAINNET, DEFAULT_API_HOST } from '@opinion-labs/opinion-clob-sdk';
const client = new Client({
host: DEFAULT_API_HOST,
apiKey: 'your_api_key',
chainId: CHAIN_ID_BNB_MAINNET, // 56
rpcUrl: 'your_rpc_url',
privateKey: '0x...' as `0x${string}`,
multiSigAddress: '0x...' as `0x${string}`,
conditionalTokensAddress: '0xAD1a38cEc043e70E83a3eC30443dB285ED10D774',
multiSendAddress: '0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526',
feeManagerAddress: '0xC9063Dc52dEEfb518E5b6634A6b8D624bc5d7c36',
enableTradingCheckInterval: 3600,
quoteTokensCacheTtl: 3600,
marketCacheTtl: 300,
proxyUrl: 'http://127.0.0.1:7890', // Optional HTTP proxy
});Required Parameters
host
Type: string
Description: Opinion API host URL
Default: No default (required)
apiKey
Type: string
Description: API authentication key provided by Opinion Labs
Default: No default (required)
How to obtain: fill out this short application form
Security: Store API keys in environment variables, never in source code.
chainId
Type: number
Description: Blockchain network chain ID
Supported values:
56- BNB Chain Mainnet (production)
rpcUrl
Type: string
Description: Blockchain RPC endpoint URL
Default: No default (required)
Common providers:
BNB Chain Mainnet:
https://bsc-dataseed.binance.orgBNB Chain (Nodereal): https://bsc.nodereal.io
privateKey
Type: `0x${string}`
Description: Private key for signing orders and transactions
Format: 64-character hex string with 0x prefix
Critical Security:
Never commit private keys to version control
Use environment variables or secure key management systems
Ensure the associated address has BNB for gas fees
This is the signer address, may differ from multiSigAddress
multiSigAddress
Type: Address
Description: Multi-signature wallet address (your assets/portfolio wallet)
Format: Ethereum address (checksummed or lowercase)
Relationship to privateKey:
privateKey-> Signer address (signs orders/transactions)multiSigAddress-> Assets address (holds funds/positions)Can be the same address or different (e.g., hot wallet signs for cold wallet)
Where to find:
Check your Opinion platform "My Profile" section
Or use the wallet address where you hold USDT/positions
Optional Parameters
conditionalTokensAddress
Type: Address
Description: ConditionalTokens contract address
Default: 0xAD1a38cEc043e70E83a3eC30443dB285ED10D774 (BNB Chain mainnet)
When to set: Only if using a custom deployment
multiSendAddress
Type: Address
Description: Gnosis Safe MultiSend contract address
Default: 0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526
When to set: Only if using a custom Gnosis Safe deployment
feeManagerAddress
Type: Address
Description: Fee rate management contract address
Default: 0xC9063Dc52dEEfb518E5b6634A6b8D624bc5d7c36
When to set: Only if using a custom deployment
enableTradingCheckInterval
Type: number
Description: Cache duration (in seconds) for trading approval checks
Default: 3600 (1 hour)
Range: 0 to infinity
Impact:
Higher values -> Fewer RPC calls -> Faster performance
0-> Always check -> Slower but always currentRecommended:
3600(approvals rarely change)
quoteTokensCacheTtl
Type: number
Description: Cache duration (in seconds) for quote token data
Default: 3600 (1 hour)
Range: 0 to infinity
Impact:
Quote tokens rarely change
Higher values improve performance
Recommended:
3600or higher
marketCacheTtl
Type: number
Description: Cache duration (in seconds) for market data
Default: 300 (5 minutes)
Range: 0 to infinity
Impact:
Markets change frequently (prices, status)
Lower values -> More current data
Recommended:
300for balance of performance and freshness
proxyUrl
Type: string
Description: HTTP proxy URL for API requests
Default: undefined (no proxy)
Environment Variables
Using .env Files
Create a .env file in your project root:
Load in your code:
Using System Environment Variables
Set in shell:
Then access in your code:
Configuration Patterns
Multi-Environment Setup
Manage different environments (dev, staging, prod):
Factory Function
Organize configuration in a factory function:
Read-Only Client
For applications that only read data (no trading):
Performance Tuning
High-Frequency Trading
For trading bots with frequent API calls:
Analytics/Research
For data analysis with less frequent updates:
Real-Time Monitoring
For dashboards requiring fresh data:
Smart Contract Addresses
BNB Chain Mainnet (Chain ID: 56)
The following smart contract addresses are used by the Opinion CLOB TypeScript SDK on BNB Chain mainnet:
ConditionalTokens
0xAD1a38cEc043e70E83a3eC30443dB285ED10D774
ERC1155 conditional tokens contract for outcome tokens
MultiSend
0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526
Gnosis Safe MultiSend contract for batch transactions
FeeManager
0xC9063Dc52dEEfb518E5b6634A6b8D624bc5d7c36
Fee rate management contract
These addresses are automatically used by the SDK when you specify chainId: 56. You only need to provide custom addresses if you are using a custom deployment.
Verification:
ConditionalTokens: View on BscScan
MultiSend: View on BscScan
FeeManager: View on BscScan
Next Steps
API Reference: All Supported Methods
Configuration Guide: Configuration
Core Concepts: Architecture
Troubleshooting: Common Issues
Last updated