useWinningBid
Hook for getting the winning bid of an auction listing on a Marketplace contract.
import { useWinningBid } from "@thirdweb-dev/react";
Usage
Provide your marketplace contract instance and the listing ID as arguments to the hook.
import { useContract, useWinningBid } from "@thirdweb-dev/react";
// Your marketplace contract address
const contractAddress = "{{contract_address}}";
// The listing ID to check
const listingId = "{{listing_id}}";
function App() {
const { contract } = useContract(contractAddress, "marketplace");
const { data, isLoading, error } = useWinningBid(contract, listingId);
}
Configuration
listingId (required)
The ID of the listing to get the winning bid for.
If the listing cannot be found, is not an auction listing, or is not active, the error
property will be set.
import { useContract, useWinningBid } from "@thirdweb-dev/react";
// Your marketplace contract address
const contractAddress = "{{contract_address}}";
// The listing ID to check
const listingId = "{{listing_id}}";
function App() {
const { contract } = useContract(contractAddress, "marketplace");
const { data, isLoading, error } = useWinningBid(
contract,
listingId,
);
}
Return Value
The hook's data
property, once loaded, is an object of type Offer
, or undefined
if no winning bid exists.
{
/**
* The id of the listing.
*/
listingId: BigNumberish;
/**
* The address of the buyer who made the offer.
*/
buyerAddress: string;
/**
* The quantity of tokens to be bought.
*/
quantityDesired: BigNumberish;
/**
* The amount of coins offered per token.
*/
pricePerToken: BigNumber;
/**
* The `CurrencyValue` of the listing. Useful for displaying the price information.
*/
currencyValue: CurrencyValue;
/**
* The currency contract address of the offer token.
*/
currencyContractAddress: string;
} | undefined;