Fill orders
This page demonstrates how an order can be filled. For fulfillment to occur, the user must have sufficient funds to cover the asking price of the order.
Immutable provides two distinct types of orders:
- Listings: These are orders initiated by an NFT owner who intends to sell their asset on a marketplace. Listings are considered sell orders.
- Bids: Representing a prospective buyer's intention to acquire an asset, bids allow users to express their interest in purchasing a specific asset. Users can place a bid on the order book, anticipating a match with a seller. Listings are considered buy orders.
Get, sign and send transactions for fulfillment
This call returns actions that are required to fulfill an order. For fulfillment all actions are transaction actions and include a type and builder method that can be used to generate the raw transaction for submission. The purpose of these transactions are as follows:
APPROVAL
- An approval transaction is required to be submitted before the fulfillment transaction if spending an ERC20 token and the seaport contract does not yet have the required allowance.FULFILL_ORDER
- The fulfillment transaction to be submitted to fulfill the order.
The taker
below is any ethers
compatible Signer
or Wallet
instance for the user creating the listing.
The fulfillOrder
call also returns the expiry for the transactions (if an user submits a transaction after the expiration it will fail on chain) and the order
entity with confirmed fee information.
Please be advised that all fees and quantities within our system are denoted in the smallest unit of the respective currency, and decimal representations are not supported.
For instance, IMX, which has 18 decimal places, will have a fee of 0.000000000000000001 IMX represented as "1".
Similarly, 1 IMX is represented as "1000000000000000000" in our system.
import { orderbook } from '@imtbl/sdk';
import { Signer } from 'ethers'; // ethers v5
const fulfillListing = async (
client: orderbook.Orderbook,
signer: Signer,
listingId: string
): Promise<void> => {
const fulfiller = await signer.getAddress();
const { actions, expiration, order } = await client.fulfillOrder(
listingId,
fulfiller,
[{
amount: '1000000', // Insert taker ecosystem/marketplace fee here
recipientAddress: '0xFooBar', // Replace address with your own marketplace address
}]
);
console.log(`Fulfilling listing ${order}, transaction expiry ${expiration}`);
for (const action of actions) {
if (action.type === orderbook.ActionType.TRANSACTION) {
const builtTx = await action.buildTransaction();
console.log(`Submitting ${action.purpose} transaction`);
await signer.sendTransaction(builtTx);
}
}
};
The order is now filled. You can poll Get orders for the off-chain representation of the order. It will asynchronously transition to FILLED
once on-chain events have been registered by Immutable services.