DirectListings
Functionality available for contracts that implement the IDirectListings
interface.
approveBuyerForReservedListing
Approve a wallet address to be able to buy a reserved listing.
const txResult = await contract.directListings.approveBuyerForReservedListing(
"{{listing_id}}",
"{{wallet_address}}",
);
Configuration
buyFromListing
Buy an NFT from a listing.
const txResult = await contract.directListings.buyFromListing(
"{{listing_id}}",
"{{quantity}}",
"{{wallet_address}}",
);
Configuration
cancelListing
Cancel a listing that you created.
Only the creator of the listing can cancel it.
const txResult = await contract.directListings.cancelListing("{{listing_id}}");
Configuration
createListing
Create a new direct listing on the marketplace.
const txResult = await contract.directListings.createListing({
assetContractAddress: "{{asset_contract_address}}", // Required - smart contract address of NFT to sell
tokenId: "{{token_id}}", // Required - token ID of the NFT to sell
pricePerToken: "{{price_per_token}}", // Required - price of each token in the listing
currencyContractAddress: "{{currency_contract_address}}", // Optional - smart contract address of the currency to use for the listing
isReservedListing: false, // Optional - whether or not the listing is reserved (only specific wallet addresses can buy)
quantity: "{{quantity}}", // Optional - number of tokens to sell (1 for ERC721 NFTs)
startTimestamp: new Date(), // Optional - when the listing should start (default is now)
endTimestamp: new Date(new Date().getTime() + 7 * 24 * 60 * 60 * 1000), // Optional - when the listing should end (default is 7 days from now)
});
Configuration
getAll
Retrieve data for all direct listings on the marketplace.
const allListings = await contract.directListings.getAll();
Configuration
getAllValid
Get all the valid direct listings on the marketplace.
A listing is considered valid if the:
- Seller still owns the NFT
- Listing has not expired (time is before endTimeInSeconds)
- Listing has not been canceled
- Listing has not been bought out (all quantity of the NFTs have not been purchased)
const validListings = await contract.directListings.getAllValid();
Configuration
getListing
Retrieve data for a specific direct listing on the marketplace using the listing ID.
const listing = await contract.directListings.getListing("{{listing_id}}");
Configuration
getTotalCount
Get the total number of direct listings on the marketplace.
const numListings = await contract.directListings.getTotalCount();
Configuration
isBuyerApprovedForListing
Check if a buyer is approved to purchase a reserved listing.
const isApproved = await contract.directListings.isBuyerApprovedForListing(
"{{listing_id}}",
"{{wallet_address}}",
);
Configuration
isCurrencyApprovedForListing
Check whether you can use a specific currency to purchase a listing.
const isApproved = await contract.directListings.isCurrencyApprovedForListing(
"{{listing_id}}",
"{{currency_contract_address}}",
);
Configuration
revokeBuyerApprovalForReservedListing
Revoke approval for a buyer to purchase a reserved listing.
const txResult =
await contract.directListings.revokeBuyerApprovalForReservedListing(
"{{listing_id}}",
"{{wallet_address}}",
);
Configuration
revokeCurrencyApprovalForListing
Revoke approval for a currency to purchase a listing.
const txResult = await contract.directListings.revokeCurrencyApprovalForListing(
"{{listing_id}}",
"{{currency_contract_address}}",
);
Configuration
updateListing
Update a previously created listing.
const txResult = await contract.directListings.updateListing("{{listing_id}}", {
assetContractAddress: "{{asset_contract_address}}", // Required - smart contract address of NFT to sell
tokenId: "{{token_id}}", // Required - token ID of the NFT to sell
pricePerToken: "{{price_per_token}}", // Required - price of each token in the listing
currencyContractAddress: "{{currency_contract_address}}", // Optional - smart contract address of the currency to use for the listing
isReservedListing: false, // Optional - whether or not the listing is reserved (only specific wallet addresses can buy)
quantity: "{{quantity}}", // Optional - number of tokens to sell (1 for ERC721 NFTs)
startTimestamp: new Date(), // Optional - when the listing should start (default is now)
endTimestamp: new Date(new Date().getTime() + 7 * 24 * 60 * 60 * 1000), // Optional - when the listing should end (default is 7 days from now)
});