Docs

useCreateDirectListingBatch

Create multiple direct listings in one batch

Example

const Component = () => {
  const { contract } = useContract("{{contract_address}}");
  const {
    mutate: createDirectListingBatch,
    isLoading,
    error,
  } = useCreateDirectListingBatch(contract);

  if (error) {
    console.error("failed to create direct listing batch", error);
  }

  // Sample data
  const directListingData = [
    {
      assetContractAddress: "nft-contract-address",
      tokenId: "token-id-1",
      quantity: "quantity-1",
      currencyContractAddress: "currency-address",
      pricePerToken: 1,
    },
    {
      assetContractAddress: "nft-contract-address",
      tokenId: "token-id-2",
      quantity: 1,
      currencyContractAddress: "currency-address",
      pricePerToken: 0,
    },
  ];
  return (
    <button
      disabled={isLoading}
      onClick={() => createDirectListingBatch(directListingData)}
    >
      Create batch Direct Listing!
    </button>
  );
};

Parameters

Returns

a mutation object that can be used to create a new batch of direct listings