Skip to main content

MarketplaceV3.directListings property

Direct listings

Signature:

get directListings(): MarketplaceV3DirectListings<DirectListingsLogic>;

Remarks

Create and manage direct listings in your marketplace.

// Data of the listing you want to create
const listing = {
// address of the contract the asset you want to list is on
assetContractAddress: "0x...",
// token ID of the asset you want to list
tokenId: "0",
// how many of the asset you want to list
quantity: 1,
// address of the currency contract that will be used to pay for the listing
currencyContractAddress: NATIVE_TOKEN_ADDRESS,
// The price to pay per unit of NFTs listed.
pricePerToken: 1.5,
// when should the listing open up for offers
startTimestamp: new Date(Date.now()),
// how long the listing will be open for
endTimestamp: new Date(Date.now() + 5 * 24 * 60 * 60 * 1000),
// Whether the listing is reserved for a specific set of buyers.
isReservedListing: false,
};

const tx = await contract.directListings.createListing(listing);
const receipt = tx.receipt; // the transaction receipt
const id = tx.id; // the id of the newly created listing

// And on the buyers side:
// The ID of the listing you want to buy from
const listingId = 0;
// Quantity of the asset you want to buy
const quantityDesired = 1;

await contract.directListings.buyFromListing(listingId, quantityDesired);