Marketplace
When using the Marketplace smart contract, additional top-level functionality is available to use.
To access the top-level functionality, provide the marketplace
contract type when creating the contract instance:
Contract contract = sdk.GetContract("0x...");
Marketplace marketplace = contract.marketplace;
Auction - CancelListing
Cancel a listing that you made.
Note: Auction listings cannot be canceled if a bid has been made.
var data = await marketplace.auction.CancelListing("{{listing_id}}");
Configuration
Auction - CreateListing
List an NFT for sale in an auction listing on the marketplace.
var data = await marketplace.auction.CreateListing(new NewAuctionListing() {
assetContractAddress = "{{contract_address}}",
tokenId = "0",
startTimestamp = DateTime.Now.Ticks,
buyoutPricePerToken = "{{price}}",
listingDurationInSeconds = 86400,
quantity = 1,
});
Configuration
assetContractAddress
The address of the NFT smart contract that you are listing.
Must be a string
.
tokenId
The token ID of the NFT to list for sale.
Must be a string
.
startTimestamp
The date and time that the listing should start.
Must be a long
.
listingDurationInSeconds
How long the auction is open for, in seconds.
Must be an int
.
quantity
The quantity of the NFT to list for sale.
Only relevant for ERC1155 NFTs. For ERC721 NFTs, this value should be 1
.
Must be an int
.
currencyContractAddress
The address of the currency contract that will be used to pay for the listing.
Must be a string
.
buyoutPricePerToken
The price that users must pay to purchase the NFT from the auction, immediately closing the auction and executing a sale event for both buyer and seller.
Must be a string
.
reservePricePerToken
The minimum bid that will be accepted for the NFT.
Bids below this amount cannot be placed on the auction.
Must be a string
.
Auction - ExecuteSale
Close the auction for both buyer and seller.
This means that the NFT is transferred to the buyer, and the seller is paid the amount of the winning bid.
var data = await marketplace.auction.ExecuteSale("{{listing_id}}");
Configuration
Auction - GetListing
Get the details of a listing using the listing ID.
var data = await marketplace.auction.GetListing("{{listing_id}}");
Configuration
listingId
The ID of the listing to get the details for.
Must be a string
.
Return Value
Returns an AuctionListing
struct, containing the following properties:
{
string startTimeInEpochSeconds;
string endTimeInEpochSeconds;
string reservePrice;
CurrencyValue reservePriceCurrencyValuePerToken;
string id;
string sellerAddress;
string assetContractAddress;
string tokenId;
NFTMetadata asset;
int quantity;
string currencyContractAddress;
string buyoutPrice;
CurrencyValue buyoutCurrencyValuePerToken;
int type;
}
Auction - GetMinimumNextBid
Get the value that the next bid must be in order to be accepted.
- If there is no current bid, this value is the reserve price.
- If there is a current bid, this value is the current bid plus the bid buffer.
var data = await marketplace.auction.GetMinimumNextBid("{{listing_id}}");
Configuration
Auction - GetWinner
Get the address that won an auction after an auction has ended.
var data = await marketplace.auction.GetWinner("{{listing_id}}");
Configuration
Auction - GetWinningBid
Get the current highest bid of an active auction.
var data = await marketplace.auction.GetWinningBid("{{listing_id}}");
Configuration
Direct - CancelListing
Cancel a direct listing you created.
Direct listings can be canceled at any time, unless a buyout has already occurred.
var data = await marketplace.direct.CancelListing("{{listing_id}}");
Configuration
Direct - CreateListing
List an NFT for sale on the marketplace for direct purchase.
var data = await marketplace.direct.CreateListing(new NewDirectListing()
{
assetContractAddress = "{{contract_address}}",
tokenId = "{{token_id}}",
startTimestamp = DateTime.Now.Ticks,
listingDurationInSeconds = 86400,
quantity = 1,
currencyContractAddress = "{{contract_address}}",
reservePricePerToken = "{{reserve_price}}",
buyoutPricePerToken = "{{buyout_price}}"
});
Configuration
assetContractAddress
The address of the NFT smart contract the asset you want to list is on.
Must be a string
.
tokenId
The token ID of the NFT you want to list.
Must be an int
.
startTimestamp
The date and time when the listing should open up for offers.
Must be a long
.
listingDurationInSeconds
How long the listing is open for, in seconds.
Must be an int
.
quantity
The quantity of NFTs to list.
Only applicable for ERC1155 NFTs. For ERC721 NFTs, this should be 1
.
Must be an int
.
currencyContractAddress
The address of the currency contract that will be used to pay for the listing.
Defaults to the native currency of the network, i.e. Ether for Ethereum.
Must be a string
.
buyoutPricePerToken
The price that users can buy the NFT for.
Must be a string
.
reservePricePerToken
The minimum price that users can bid for the NFT.
Must be a string
.
Direct - GetActiveOffer
Get an active offer on a listing from a specific wallet address, if there is one.
var data = await marketplace.direct.GetActiveOffer("{{listing_id}}", "{{wallet_address}}");
Configuration
listingId
The ID of the listing to get the active offer for.
Must be a string
.
offerorAddress
The wallet address of the offeror.
Must be a string
.
Return Value
Returns an Offer
struct with the following properties:
{
string listingId;
string buyerAddress;
int quantityDesired;
string pricePerToken;
CurrencyValue currencyValue;
string currencyContractAddress;
}
Direct - GetListing
Get a direct listing by its ID.
var data = await marketplace.direct.GetListing("{{listing_id}}");
Configuration
listingId
The ID of the listing to get.
Must be a string
.
Return Value
Returns a DirectListing
object containing the following properties:
{
string id;
string sellerAddress;
string assetContractAddress;
string tokenId;
NFTMetadata asset;
int quantity;
string currencyContractAddress;
string buyoutPrice;
CurrencyValue buyoutCurrencyValuePerToken;
int type;
string startTimeInSeconds;
string secondsUntilEnd;
}
GetActiveListings
Get all active listings on the marketplace, both direct and auction listings.
An active listing means it can be bought or bid on.
var data = await marketplace.GetActiveListings();
Configuration
filter (optional)
A filter to apply to the listings returned.
var data = await marketplace.GetActiveListings(new MarketplaceFilter()
{
seller = "{{wallet_address}}", // Only show results from this seller
tokenContract = "{{contract_address}}", // Only show results from this contract address
tokenId = "{{token_id}}", // Only show results with this token ID
start = 0, // Pagination: start index
count = 100 // Pagination: number of results to return
});
Return Value
Returns a list of Listing
structs, each containing the following properties:
{
string id;
string sellerAddress;
string assetContractAddress;
string tokenId;
NFTMetadata asset;
int quantity;
string currencyContractAddress;
string buyoutPrice;
CurrencyValue buyoutCurrencyValuePerToken;
int type;
}
GetAllListings
Get all the listings on the marketplace, including inactive ones.
var data = await marketplace.GetAllListings();
Configuration
filter (optional)
A filter to apply to the listings returned.
var data = await marketplace.GetAllListings(new MarketplaceFilter()
{
seller = "{{wallet_address}}", // Only show results from this seller
tokenContract = "{{contract_address}}", // Only show results from this contract address
tokenId = "{{token_id}}", // Only show results with this token ID
start = 0, // Pagination: start index
count = 100 // Pagination: number of results to return
});
Return Value
Returns a list of Listing
structs, each containing the following properties:
{
string id;
string sellerAddress;
string assetContractAddress;
string tokenId;
NFTMetadata asset;
int quantity;
string currencyContractAddress;
string buyoutPrice;
CurrencyValue buyoutCurrencyValuePerToken;
int type;
}
GetOffers
Get all the offers made on a listing.
var data = await marketplace.GetOffers("{{listing_id}}");
Configuration
listingId
The ID of the listing to get offers for.
Must be a string
.
Return Value
Returns a list of Offer
structs, each containing the following properties:
{
public string listingId;
public string buyerAddress;
public int quantityDesired;
public string pricePerToken;
public CurrencyValue currencyValue;
public string currencyContractAddress;
}
MakeOffer
Create a new bid on an auction listing or a new offer on a direct listing.
var data = await marketplace.MakeOffer("{{listing_id}}", "{{price}}", 1);