Creating trades
Creating a trade is also known as filling an order, or buying an asset. A user executes a trade by agreeing to purchase an asset at the terms specified in the order and then becomes the new owner of the asset.
Core SDK
1. Initialize the Core SDK
In order to use the Core SDK, you need to initialize it.
2. Generate signers
Creating a trade for a user requires a user's signature, so your application will need to create signers. See the guide on how to generate signers.
3. Create the trade
- You cannot set more than 3 recipients
- You cannot set the same recipient more than once
- The combined fee percentage can’t exceed 100%
- Individual percentage fees can’t be <= 0%
- Typescript Core SDK
📚SDK reference
Creating a trade for the order with ID 7232
:
const createTrade = async (wallet: WalletConnection, orderId: number) => {
const ethAddress = await wallet.ethSigner.getAddress();
const tradeData = {
order_id: orderId,
user: ethAddress
} as GetSignableTradeRequest;
const response = await client.createTrade(wallet, tradeData);
return response;
}
createTrade(wallet, 7232)
.then((result) => {
console.log(result)
})
.catch((e) => {
console.log(e)
})
Example response:
{
trade_id: 226892, // ID of trade within Immutable X
status: '' // Current status of trade
}