Place Order
Submit a signed order on behalf of a user.
Usage (Recommended)
Use placeOrderForUserFromBuildResult() with the output from buildOrderForSigning():
import { BuilderClient, OrderSide, OrderType } from '@opinion-labs/opinion-clob-sdk';
const builder = new BuilderClient({
host: 'https://openapi.opinion.trade/openapi',
builderApiKey: 'YOUR_BUILDER_KEY',
chainId: 56,
});
// Step 1: Build the order
const orderData = await builder.buildOrderForSigning({
marketId: 123,
tokenId: 'token_id',
userWalletAddress: safeAddress,
side: OrderSide.BUY,
orderType: OrderType.LIMIT_ORDER,
amount: 10,
price: '0.5',
signerAddress: userEOA,
});
// Step 2: User signs the struct hash
const signature = await user.signHash(orderData.structHash);
// Step 3: Place the order (convenience method)
const result = await builder.placeOrderForUserFromBuildResult(
orderData,
signature,
safeAddress,
);Convenience Method
buildResult
BuildOrderResult
Yes
Result from buildOrderForSigning()
signature
string
Yes
User's signature (0x-prefixed hex string)
userWalletAddress
string
Yes
User's Safe wallet address (must match order.maker)
postOnly
boolean
No
Post-only mode for limit orders; crossing orders are cancelled instead of taking liquidity.
Full Method
For advanced use cases, you can call placeOrderForUser() directly:
order
Record<string, string>
Yes
Order struct from buildOrderForSigning()
signature
string
Yes
User's signature (0x-prefixed hex string)
userWalletAddress
string
Yes
User's Safe wallet address (must match order.maker)
marketId
number
No
Market ID
orderType
number
No
Order type (1=market, 2=limit)
price
string
No
Order price
currencyAddress
string
No
Quote token address
postOnly
boolean
No
Post-only mode for limit orders; crossing orders are cancelled instead of taking liquidity.
Notes
The convenience method
placeOrderForUserFromBuildResult()is recommended. It automatically extractsmarketId,orderType,price, andcurrencyAddressfrom the build result.The
order.makermust matchuserWalletAddressor the request will be rejected.The signature must be a hex string starting with
0x.Order placement is gasless (counts toward the 2,000/day limit).
Post-only is supported only for limit orders; orders that would cross the spread are cancelled instead of taking liquidity.
Last updated