Gas Operations
Gas vs Gas-Free Operations
Overview
The Opinion CLOB SDK implements a hybrid execution model: off-chain order matching via CLOB infrastructure eliminates gas costs for order operations, while direct smart contract invocations require BNB native token for transaction fees.
Gas-Free Operations
Off-Chain Order Book
The Central Limit Order Book functions as an off-chain matching engine. Orders are authenticated via EIP712 cryptographic signatures and submitted to the Opinion API. On-chain settlement is executed asynchronously by backend infrastructure, abstracting gas costs from end users.
Supported Gas-Free Operations
Market Data Queries
get_markets()- Market metadata retrievalget_market()- Individual market detailsget_categorical_market()- Categorical market informationget_orderbook()- Real-time order book snapshotsget_latest_price()- Current market pricesget_price_history()- Historical price data (OHLCV candles)get_quote_tokens()- Supported collateral currenciesget_fee_rates()- Fee schedule information
Order Management
place_order()- Order submission (market and limit)cancel_order()- Single order cancellationcancel_all_orders()- Batch order cancellationget_my_orders()- Active order retrievalget_order_by_id()- Order status queries
Position Tracking
get_my_balances()- Token balance queriesget_my_positions()- Position inventoryget_my_trades()- Trade history
Technical Implementation
EIP712 Signature Protocol
Orders employ typed structured data signatures conforming to EIP712 specification. Signatures provide cryptographic proof of authorization without blockchain state modification.
Signature Generation Flow:
Order parameters encoded per EIP712 TypedData standard
Digest computed:
keccak256("\x19\x01" β domainSeparator β structHash)ECDSA signature generated via secp256k1 curve
Signature transmitted with order to API endpoint
Backend performs ecrecover validation (signer authenticity)
Matched orders batch-settled on-chain (gas paid by infrastructure)
Pseudocode:
Gas-Required Operations
On-Chain Smart Contract Invocations
Direct blockchain transactions invoke smart contract methods and require gas payment in BNB native tokens. These operations modify on-chain state and are irreversible post-confirmation.
Operations Requiring Gas
Token Approval (One-Time Setup)
enable_trading()- Grant ERC20/ERC1155 allowances to exchange contracts
Position Operations
split()- InvokeConditionalTokens.splitPosition()(USDT β outcome tokens)merge()- InvokeConditionalTokens.mergePositions()(outcome tokens β USDT)redeem()- InvokeConditionalTokens.redeemPositions()(claim winning payouts)
State Query (RPC Call, No Gas)
check_enable_trading()- Read contract allowance state viaeth_call
Gas Cost Analysis
BNB Chain Network Parameters
Block Time
~1.5s
Average block production interval
Gas Price
0.05 Gwei
Minimum gas price (EIP-1559 base fee)
Finality Threshold
10 blocks
Recommended confirmation depth (~15s)
Operation Gas Consumption Estimates
enable_trading() (2 approvals)
~100,000
0.000005 BNB
$0.003
split()
~150,000
0.0000075 BNB
$0.0045
merge()
~120,000
0.000006 BNB
$0.0036
redeem()
~180,000
0.000009 BNB
$0.0054
Cost Formula:
Variability Factors:
Network congestion (gas price auction)
Contract state complexity (storage operations)
Transaction data size (calldata cost)
BNB market price volatility
Implementation Examples
Enable Trading (Required Once)
Required Approvals:
USDT Contract β Exchange contract (for collateral deposits)
ConditionalTokens Contract β Exchange contract (for outcome token trading)
Split Position
Use Cases:
Creating outcome tokens for selling
Market making strategies
Arbitrage opportunities
Merge Position
Requirements:
Must hold equal amounts of both outcome tokens
Amount specified in Wei (18 decimals)
Redeem Winnings
Redemption Logic:
Markets resolved to YES: 1 YES token β 1 USDT
Markets resolved to NO: 1 NO token β 1 USDT
Losing outcome tokens become worthless
Gas Balance Requirements
Recommended BNB Holdings
Maintain sufficient BNB balance to execute gas-required operations without transaction failures.
Allocation Guidelines:
Initial setup
0.001 BNB (~$0.60)
Single enable_trading() call
High-frequency
0.1 BNB (~$60.00)
Hundreds of transactions, failover capacity
Balance Monitoring
Position Management Planning
Structure trading strategies to minimize split/merge operations.
Example Strategy:
Execute single split to create large token inventory
Trade via gas-free CLOB orders
Merge/redeem only when exiting position or market resolves
Next Steps
Precision - Token decimal systems
Last updated