Skip to content

Latest commit

 

History

History
52 lines (39 loc) · 2.32 KB

take-list-as-seller-tx.md

File metadata and controls

52 lines (39 loc) · 2.32 KB
description
Take the 𝔉rc20 token purchase listing as a seller

Take list as seller - tx

Example of Fixes Inscription data string:

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

Transaction parameters:

KeyRequiredFTypeDescription
ticktruet.StringTicker: identity of the 𝔉rc20 token
batchSellItemstruet.Dictionary({ key: t.String, value: t.UFix64 })

The dictionary for selling:

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

📓Note: The key of batchSellItems 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 txUserTakeAsSeller from "@fixes/contracts/transactions/marketplace/user-take-as-seller-with-commission.cdc?raw";

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

Transaction source code

{% @github-files/github-code-block url="https://github.com/fixes-world/fixes/blob/main/cadence/transactions/marketplace/user-take-as-seller-with-commission.cdc" %}

Related docs