Filling an order

Before a user can send a transaction to fill an order, they need to have proper tokens. This is explained in more detail in Preparing for transactions.

Before starting this tutorial, make sure you've installed Third party helpers.

To fill an opened order, you only need to pass the correct field you received from Searching ordersto send the transaction.

const orderFees = order.fees.map((fee) => {
    return {
      amount: fee.amount,
      recipient: fee.recipient,
      feeData: fee.feeData || '0x'
    }
})

const fillTx = await nftSwapSdk.fillSignedOrder({
    direction: order.direction,
    maker: order.maker,
    taker: order.taker,
    // Convert to seconds
    expiry: new Date(order.expiry).getTime() / 1000,
    nonce: order.nonce,
    erc20Token: order.erc20Token,
    erc20TokenAmount: order.erc20TokenAmount,
    fees: orderFees,
    erc721Token: MY_COLLECTION_ADDRESS,
    erc721TokenId: order.tokenId,
    erc721TokenProperties: [],
    signature: order.signature
})

Ultimately, the NFT swap SDK calls either the sellERC721 or the buyERC721 function from 0x.

Last updated