useValidEnglishAuctions

Hook to get all valid English auctions from a Marketplace V3 contract.

A listing is considered valid if the:

  • Auction has not expired (i.e. current time is before the end time of the auction)

  • Auction has not been canceled

  • Auction has not been bought out (all quantity has been sold)

This hook is only for Marketplace V3 contracts.

For Marketplace contracts, use useActiveListings instead.

Example

import {
useValidEnglishAuctions,
useContract,
} from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress, "marketplace-v3");
const {
data: englishAuctions,
isLoading,
error,
} = useValidEnglishAuctions(contract);
}
function useValidEnglishAuctions(
contract: RequiredParam<MarketplaceV3>,
): UseQueryResult<Array<EnglishAuction>, unknown>;

Parameters

Instance of a marketplace v3 contract

Type

let contract: RequiredParam<MarketplaceV3>;

The filter object allows you to filter the auctions returned by the hook.

import { useEnglishAuctions, useContract } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress, "marketplace-v3");
const {
data: englishAuctions,
isLoading,
error,
} = useEnglishAuctions(
contract,
// highlight-start
{
count: 100, // Number of auctions to fetch
offeror: "{{offeror_address}}", // Has offers from this address
seller: "{{seller_address}}", // Being sold by this address
start: 0, // Start from this index (pagination)
tokenContract: "{{token_contract_address}}", // Only show NFTs from this collection
tokenId: "{{token_id}}", // Only show NFTs with this ID
},
// highlight-end
);
}

Type

let filter: MarketplaceFilter;

Returns

let returnType: UseQueryResult<Array<EnglishAuction>, unknown>;

A Query Result object that includes an array of english auctions The hook's data property, once loaded, is an array of EnglishAuction objects, each containing the following properties:

Array<{
// The id of the auction
id: string;
// The address of the creator of auction.
creatorAddress: string;
// The address of the asset being auctioned.
assetContractAddress: string;
// The ID of the token to auction.
tokenId: string;
// The quantity of tokens to include in the auction.
// For ERC721s, this value should always be 1 (and will be forced internally regardless of what is passed here).
quantity: string;
// The address of the currency to accept for the auction.
currencyContractAddress: string;
// The minimum price that a bid must be in order to be accepted.
minimumBidAmount: string;
// The `CurrencyValue` of the minimum bid amount.
// Useful for displaying the price information.
minimumBidCurrencyValue: CurrencyValue;
// The buyout price of the auction.
buyoutBidAmount: string;
// The `CurrencyValue` of the buyout price.
// Useful for displaying the price information.
buyoutCurrencyValue: CurrencyValue;
// This is a buffer e.g. x seconds.
// If a new winning bid is made less than x seconds before expirationTimestamp, the
// expirationTimestamp is increased by x seconds.
timeBufferInSeconds: number;
// This is a buffer in basis points e.g. x%.
// To be considered as a new winning bid, a bid must be at least x% greater than
// the current winning bid.
bidBufferBps: number;
// The start time of the auction.
startTimeInSeconds: number;
// The end time of the auction.
endTimeInSeconds: number;
// The asset being auctioned.
asset: NFTMetadata;
// Whether the listing is CREATED, COMPLETED, or CANCELLED.
status: Status;
}>;