Private
_chainAllow listings from any NFT contract
Rest
...args: []Rest
...args: []Restrict listing NFTs only from the specified NFT contract address. It is possible to allow listing from multiple contract addresses.
Rest
...args: [contractAddress: string]Rest
...args: [contractAddress: string]Auctions
Create and manage auctions in your marketplace.
// Data of the auction you want to create
const auction = {
// 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",
// when should the listing open up for offers
startTimestamp: new Date(),
// how long the listing will be open for
listingDurationInSeconds: 86400,
// 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,
// how much people would have to bid to instantly buy the asset
buyoutPricePerToken: "10",
// the minimum bid that will be accepted for the token
reservePricePerToken: "1.5",
}
const tx = await contract.auction.createListing(auction);
const receipt = tx.receipt; // the transaction receipt
const listingId = tx.id; // the id of the newly created listing
// And on the buyers side:
// The price you are willing to bid for a single token of the listing
const pricePerToken = 2.6;
await contract.auction.makeBid(listingId, pricePerToken);
Purchase NFTs
Rest
...args: [listingId: BigNumberish, quantityDesired?: BigNumberish, receiver?: string]Buy a Direct or Auction listing on your marketplace.
// The listing ID of the asset you want to buy
const listingId = 0;
// Quantity of the asset you want to buy
const quantityDesired = 1;
await contract.buyoutListing(listingId, quantityDesired);
Rest
...args: [listingId: BigNumberish, quantityDesired?: BigNumberish, receiver?: string]Private
contractDirect listings
Create and manage direct listings in your marketplace.
// Data of the listing you want to create
const listing = {
// address of the NFT contract the asset you want to list is on
assetContractAddress: "0x...",
// token ID of the asset you want to list
tokenId: "0",
// when should the listing open up for offers
startTimestamp: new Date(),
// how long the listing will be open for
listingDurationInSeconds: 86400,
// 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,
// how much the asset will be sold for
buyoutPricePerToken: "1.5",
}
const tx = await contract.direct.createListing(listing);
const receipt = tx.receipt; // the transaction receipt
const listingId = tx.id; // the id of the newly created listing
// And on the buyers side:
// Quantity of the asset you want to buy
const quantityDesired = 1;
await contract.direct.buyoutListing(listingId, quantityDesired);
Make an offer for a Direct or Auction Listing
Rest
...args: [listingId: BigNumberish, pricePerToken: string | number, quantity?: BigNumberish]Make an offer on a direct or auction listing
// The listing ID of the asset you want to offer on
const listingId = 0;
// The price you are willing to offer per token
const pricePerToken = 0.5;
// The quantity of tokens you want to receive for this offer
const quantity = 1;
await contract.makeOffer(
listingId,
pricePerToken,
quantity,
);
Rest
...args: [listingId: BigNumberish, pricePerToken: string | number, quantity?: BigNumberish]Set the Auction bid buffer
Rest
...args: [bufferBps: BigNumberish]A percentage (e.g. 5%) in basis points (5% = 500, 100% = 10000). A new bid is considered to be a winning bid only if its bid amount is at least the bid buffer (e.g. 5%) greater than the previous winning bid. This prevents buyers from making very slightly higher bids to win the auctioned items.
// the bid buffer in basis points
const bufferBps = 5_00; // 5%
await contract.setBidBufferBps(bufferBps);
Rest
...args: [bufferBps: BigNumberish]Set the Auction Time buffer:
Rest
...args: [bufferInSeconds: BigNumberish]Measured in seconds (e.g. 15 minutes or 900 seconds). If a winning bid is made within the buffer of the auction closing (e.g. 15 minutes within the auction closing), the auction's closing time is increased by the buffer to prevent buyers from making last minute winning bids, and to give time to other buyers to make a higher bid if they wish to.
// the time buffer in seconds
const bufferInSeconds = 60;
await contract.setTimeBufferInSeconds(bufferInSeconds);
Rest
...args: [bufferInSeconds: BigNumberish]Private
storageStatic
contractPrivate
applyOptional
filter: MarketplaceFilterGet all active listings
Optional
filter: MarketplaceFilteroptional filter parameters
Fetch all the active listings from this marketplace contract. An active listing means it can be bought or bid on.
const listings = await contract.getActiveListings();
const priceOfFirstActiveListing = listings[0].price;
Get all the listings
Optional
filter: MarketplaceFilteroptional filter parameters
Fetch all the listings from this marketplace contract, including sold ones.
const listings = await contract.getAllListings();
const priceOfFirstListing = listings[0].price;
Private
getPRIVATE FUNCTIONS
Convenience function to get either a direct or auction listing
the listing id
either a direct or auction listing
Get a listing by its listing id
const listingId = 0;
const listing = await contract.getListing(listingId);
Get all the offers for a listing
the id of the listing to fetch offers for
Fetch all the offers for a specified direct or auction listing.
const offers = await marketplaceContract.getOffers(listingId);
const firstOffer = offers[0];
Generated using TypeDoc
Create your own whitelabel marketplace that enables users to buy and sell any digital assets.
Example