This guide covers how to configure the Opinion CLOB SDK for different environments and use cases.
Client Configuration
The Client class accepts multiple configuration parameters during initialization:
from opinion_clob_sdk import Clientclient =Client(host='https://proxy.opinion.trade:8443',apikey='your_api_key',chain_id=56,rpc_url='your_rpc_url',private_key='0x...',multi_sig_addr='0x...',conditional_tokens_addr='0xAD1a38cEc043e70E83a3eC30443dB285ED10D774',multisend_addr='0x998739BFdAAdde7C933B942a68053933098f9EDa',enable_trading_check_interval=3600,quote_tokens_cache_ttl=3600,market_cache_ttl=300)
Required Parameters
host
Type: strDescription: Opinion API host URL Default: No default (required)
apikey
Type: strDescription: API authentication key provided by Opinion Labs Default: No default (required)
Type: intDescription: Cache duration (in seconds) for quote token data Default: 3600 (1 hour) Range: 0 to ∞
Impact:
Quote tokens rarely change
Higher values improve performance
Recommended: 3600 or higher
market_cache_ttl
Type: intDescription: Cache duration (in seconds) for market data Default: 300 (5 minutes) Range: 0 to ∞
Impact:
Markets change frequently (prices, status)
Lower values → More current data
Recommended: 300 for balance of performance and freshness
Environment Variables
Using .env Files
Create a .env file in your project root:
Load in your Python code:
Using System Environment Variables
Set in shell:
Then access in Python:
Configuration Patterns
Multi-Environment Setup
Manage different environments (dev, staging, prod):
Configuration Class
Organize configuration in a class:
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 SDK on BNB Chain mainnet:
Contract
Address
Description
ConditionalTokens
0xAD1a38cEc043e70E83a3eC30443dB285ED10D774
ERC1155 conditional tokens contract for outcome tokens
MultiSend
0x998739BFdAAdde7C933B942a68053933098f9EDa
Gnosis Safe MultiSend contract for batch transactions
These addresses are automatically used by the SDK when you specify chain_id=56. You only need to provide custom addresses if you're using a custom deployment.
# Default for BNB Chain - no need to specify
client = Client(chain_id=56, ...)
# Custom deployment
conditional_tokens_addr='0xYourConditionalTokensContract...'
# Default for BNB Chain - no need to specify
client = Client(chain_id=56, ...)
# Custom deployment
multisend_addr='0xYourMultiSendContract...'
# Default: check approval status every hour
enable_trading_check_interval=3600
# Check every time (no caching)
enable_trading_check_interval=0
# Check daily
enable_trading_check_interval=86400
# Default: cache for 1 hour
quote_tokens_cache_ttl=3600
# No caching (always fresh)
quote_tokens_cache_ttl=0
# Cache for 6 hours
quote_tokens_cache_ttl=21600
# Default: cache for 5 minutes
market_cache_ttl=300
# No caching (always fresh)
market_cache_ttl=0
# Cache for 1 hour
market_cache_ttl=3600
import os
from dotenv import load_dotenv
from opinion_clob_sdk import Client
# Load .env file
load_dotenv()
# Use environment variables
client = Client(
host='https://api.opinion.trade',
apikey=os.getenv('API_KEY'),
chain_id=int(os.getenv('CHAIN_ID', 56)),
rpc_url=os.getenv('RPC_URL'),
private_key=os.getenv('PRIVATE_KEY'),
multi_sig_addr=os.getenv('MULTI_SIG_ADDRESS')
)
# Linux/macOS
export API_KEY="opn_prod_abc123xyz789"
export RPC_URL=___
export PRIVATE_KEY="0x..."
export MULTI_SIG_ADDRESS="0x..."
# Windows (Command Prompt)
set API_KEY=opn_prod_abc123xyz789
set RPC_URL=___
# Windows (PowerShell)
$env:API_KEY="opn_prod_abc123xyz789"
$env:RPC_URL=___
import os
client = Client(
host='https://proxy.opinion.trade:8443',
apikey=os.environ['API_KEY'], # Raises error if not set
# ... or ...
apikey=os.getenv('API_KEY', 'default_value'), # Returns default if not set
# ...
)
from dataclasses import dataclass
import os
from opinion_clob_sdk import Client
@dataclass
class OpinionConfig:
api_key: str
rpc_url: str
private_key: str
multi_sig_address: str
chain_id: int = 56
host: str = 'https://proxy.opinion.trade:8443'
market_cache_ttl: int = 300
@classmethod
def from_env(cls):
"""Load configuration from environment variables"""
return cls(
api_key=os.environ['API_KEY'],
rpc_url=os.environ['RPC_URL'],
private_key=os.environ['PRIVATE_KEY'],
multi_sig_address=os.environ['MULTI_SIG_ADDRESS'],
chain_id=int(os.getenv('CHAIN_ID', 56))
)
def create_client(self):
"""Create Opinion Client from this configuration"""
return Client(
host=self.host,
apikey=self.api_key,
chain_id=self.chain_id,
rpc_url=self.rpc_url,
private_key=self.private_key,
multi_sig_addr=self.multi_sig_address,
market_cache_ttl=self.market_cache_ttl
)
# Usage
config = OpinionConfig.from_env()
client = config.create_client()
# Minimal configuration for read-only access
client = Client(
host='https://proxy.opinion.trade:8443',
apikey=os.getenv('API_KEY'),
chain_id=56,
rpc_url='', # Empty if not doing contract operations
private_key='0x00', # Dummy key if not placing orders
multi_sig_addr='0x0000000000000000000000000000000000000000'
)
# Can use all GET methods
markets = client.get_markets()
market = client.get_market(123)
orderbook = client.get_orderbook('token_123')
# Cannot use trading or contract methods
# client.place_order(...) # Would fail
# client.split(...) # Would fail