Skip to main content

Link reference tool

Check out our Link reference tool to understand how Link methods work without having to write any code.

Here's how you can initiate a buy order:

import { Link, ImmutableXClient, ImmutableOrderStatus} from ‘@imtbl/imx-sdk’;
const link = new Link('')
buyResults: BuyResponse = await{ orderIds: ['1', '2', '3'] });

Just like all other link SDK methods, buy returns a promise, which resolves once all operations are complete, or rejects once the link encounters a critical error.

Once a multi-buy flow is confirmed by the user, Buy will asynchronously try to buy each order in the list and then display the results.

In order to handle the various new kinds of error states that this functionality allows, will now resolve with a response report payload which matches the following types:

type SuccessOrError = 'success' | 'error';

type OrderStatus = {
status: SuccessOrError;
message?: string;

type BuyResults = {
[orderId: string]: OrderStatus;

type BuyResponse = {
result: BuyResults;

An example resolve payload from a semi-successful buy() flow:

result: {
'1': { status: 'success' },
'2': {
status: 'error',
message: 'Cannot purchase own order',
'3': { status: 'success' },

If the multi-buy flow is found to contain 0 valid orders after minimal client-side validation, then link will error out (and reject the promise it returned from the buy() method) and no orders will be purchased.


See error responses here.

IMX Whitepaper IMX Tokenomics Block Explorer Careers Contact Us