Take list as buyer - tx

Take the 𝔉rc20 token sale listing as a buyer

Example of Fixes Inscription data string:

op=list-take-buynow,tick=fixes,amt=10000.0

Transaction parameters:

KeyRequiredFTypeDescription

tick

t.String

Ticker: identity of the 𝔉rc20 token

batchBuyItems

t.Dictionary({ key: t.String, value: t.UFix64 })

The dictionary for buying:

rankedId => Amount You can get RankedListingId by querying the marketplace

📓Note: The key of batchBuyItems should be itemInMarket.rankedId which can be obtained in the response of querying listings. and the value is how much tokens you will take in the order. 𝔉rc20 trading orders support partial deal.

Transaction code example:

import txUserTakeAsBuyer from "@fixes/contracts/transactions/marketplace/user-take-as-buyer-with-commission.cdc?raw";

async function userTakeAsBuyer(
  tick: string,
  batchBuyItems: Record<string, number>
) {
  let args: Array<{ key: string; value: string }> = [];
  for (const key in batchBuyItems) {
    if (!Object.prototype.hasOwnProperty.call(batchBuyItems, key)) continue;
    args.push({
      key,
      value: batchBuyItems[key].toFixed(8),
    });
  }
  const txid = await flow.sendTransaction(txUserTakeAsBuyer, (arg, t) => [
    arg(tick, t.String),
    arg(args, t.Dictionary({ key: t.String, value: t.UFix64 })),
  ]);
  return txid;
}

Transaction source code

Last updated