useAuctionWinner
Hook for getting the winner of an auction (or english auction) on a Marketplace or MarketplaceV3 contract.
import { useAuctionWinner } from "@thirdweb-dev/react";
Usage
Provide your Marketplace contract and the listing ID as the arguments.
import { useAuctionWinner, useContract } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress, "marketplace");
const { data, isLoading, error } = useAuctionWinner(
contract,
1, // The listing id of the item that you want to get the auction winner for
);
}
Configuration
listingId (required)
The listing ID of the item that you want to get the auction winner for.
The listing must be an auction (or english auction) listing, the hook will populate the error
property if it is not.
import { useAuctionWinner, useContract } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
const listingId = "{{listing_id}}";
function App() {
const { contract } = useContract(contractAddress, "marketplace");
const { data, isLoading, error } = useAuctionWinner(
contract,
listingId, // The listing id of the item that you want to get the auction winner for
);
}
Return Value
The hook's data
property, once loaded, contains a string
representing the address of the auction winner, or undefined if there is no winner.
string | undefined;