useOffers
Hook for getting all of the offers made on a
direct listing on a Marketplace
contract.
import { useOffers, useContract } from "@thirdweb-dev/react"; function App() { const { contract } = useContract(contractAddress, "marketplace"); const { data: offers, isLoading, error, } = useOffers(contract, listingId);}
function useOffers( contract: RequiredParam<Marketplace>, listingId: RequiredParam<BigNumberish>,): | { data: undefined | Array<Record<string, any>>; dataUpdatedAt: number; error: unknown; errorUpdateCount: number; errorUpdatedAt: number; failureCount: number; failureReason: unknown; fetchStatus: FetchStatus; isError: true; isFetched: boolean; isFetchedAfterMount: boolean; isFetching: boolean; isInitialLoading: boolean; isLoading: false; isLoadingError: false; isPaused: boolean; isPlaceholderData: boolean; isPreviousData: boolean; isRefetchError: true; isRefetching: boolean; isStale: boolean; isSuccess: false; refetch: ( options?: RefetchOptions & RefetchQueryFilters<TPageData>, ) => Promise< QueryObserverResult< unknown > >; remove: () => void; status: "error"; } | { data: undefined | Array<Record<string, any>>; dataUpdatedAt: number; error: null; errorUpdateCount: number; errorUpdatedAt: number; failureCount: number; failureReason: unknown; fetchStatus: FetchStatus; isError: false; isFetched: boolean; isFetchedAfterMount: boolean; isFetching: boolean; isInitialLoading: boolean; isLoading: false; isLoadingError: false; isPaused: boolean; isPlaceholderData: boolean; isPreviousData: boolean; isRefetchError: false; isRefetching: boolean; isStale: boolean; isSuccess: true; refetch: ( options?: RefetchOptions & RefetchQueryFilters<TPageData>, ) => Promise< QueryObserverResult< unknown > >; remove: () => void; status: "success"; } | { data: undefined | Array<Record<string, any>>; dataUpdatedAt: number; error: unknown; errorUpdateCount: number; errorUpdatedAt: number; failureCount: number; failureReason: unknown; fetchStatus: FetchStatus; isError: true; isFetched: boolean; isFetchedAfterMount: boolean; isFetching: boolean; isInitialLoading: boolean; isLoading: false; isLoadingError: true; isPaused: boolean; isPlaceholderData: boolean; isPreviousData: boolean; isRefetchError: false; isRefetching: boolean; isStale: boolean; isSuccess: false; refetch: ( options?: RefetchOptions & RefetchQueryFilters<TPageData>, ) => Promise< QueryObserverResult< unknown > >; remove: () => void; status: "error"; } | { data: undefined | Array<Record<string, any>>; dataUpdatedAt: number; error: null; errorUpdateCount: number; errorUpdatedAt: number; failureCount: number; failureReason: unknown; fetchStatus: FetchStatus; isError: false; isFetched: boolean; isFetchedAfterMount: boolean; isFetching: boolean; isInitialLoading: boolean; isLoading: true; isLoadingError: false; isPaused: boolean; isPlaceholderData: boolean; isPreviousData: boolean; isRefetchError: false; isRefetching: boolean; isStale: boolean; isSuccess: false; refetch: ( options?: RefetchOptions & RefetchQueryFilters<TPageData>, ) => Promise< QueryObserverResult< unknown > >; remove: () => void; status: "loading"; };
let returnType: | { data: undefined | Array<Record<string, any>>; dataUpdatedAt: number; error: unknown; errorUpdateCount: number; errorUpdatedAt: number; failureCount: number; failureReason: unknown; fetchStatus: FetchStatus; isError: true; isFetched: boolean; isFetchedAfterMount: boolean; isFetching: boolean; isInitialLoading: boolean; isLoading: false; isLoadingError: false; isPaused: boolean; isPlaceholderData: boolean; isPreviousData: boolean; isRefetchError: true; isRefetching: boolean; isStale: boolean; isSuccess: false; refetch: ( options?: RefetchOptions & RefetchQueryFilters<TPageData>, ) => Promise< QueryObserverResult< unknown > >; remove: () => void; status: "error"; } | { data: undefined | Array<Record<string, any>>; dataUpdatedAt: number; error: null; errorUpdateCount: number; errorUpdatedAt: number; failureCount: number; failureReason: unknown; fetchStatus: FetchStatus; isError: false; isFetched: boolean; isFetchedAfterMount: boolean; isFetching: boolean; isInitialLoading: boolean; isLoading: false; isLoadingError: false; isPaused: boolean; isPlaceholderData: boolean; isPreviousData: boolean; isRefetchError: false; isRefetching: boolean; isStale: boolean; isSuccess: true; refetch: ( options?: RefetchOptions & RefetchQueryFilters<TPageData>, ) => Promise< QueryObserverResult< unknown > >; remove: () => void; status: "success"; } | { data: undefined | Array<Record<string, any>>; dataUpdatedAt: number; error: unknown; errorUpdateCount: number; errorUpdatedAt: number; failureCount: number; failureReason: unknown; fetchStatus: FetchStatus; isError: true; isFetched: boolean; isFetchedAfterMount: boolean; isFetching: boolean; isInitialLoading: boolean; isLoading: false; isLoadingError: true; isPaused: boolean; isPlaceholderData: boolean; isPreviousData: boolean; isRefetchError: false; isRefetching: boolean; isStale: boolean; isSuccess: false; refetch: ( options?: RefetchOptions & RefetchQueryFilters<TPageData>, ) => Promise< QueryObserverResult< unknown > >; remove: () => void; status: "error"; } | { data: undefined | Array<Record<string, any>>; dataUpdatedAt: number; error: null; errorUpdateCount: number; errorUpdatedAt: number; failureCount: number; failureReason: unknown; fetchStatus: FetchStatus; isError: false; isFetched: boolean; isFetchedAfterMount: boolean; isFetching: boolean; isInitialLoading: boolean; isLoading: true; isLoadingError: false; isPaused: boolean; isPlaceholderData: boolean; isPreviousData: boolean; isRefetchError: false; isRefetching: boolean; isStale: boolean; isSuccess: false; refetch: ( options?: RefetchOptions & RefetchQueryFilters<TPageData>, ) => Promise< QueryObserverResult< unknown > >; remove: () => void; status: "loading"; };
This hook uses the useEvents
hook under the hood to fetch NewOffer
events for the given listing ID.
The return value is an array of NewOffer
event objects. Each event object has the following properties:
{ offeror: string; offerId: BigNumber; assetContract: string; offer: { offerId: BigNumber; offeror: string; assetContract: string; tokenId: BigNumber; quantity: BigNumber; currency: string; totalPrice: BigNumber; expirationTimestamp: BigNumber; tokenType: "ERC721" | "ERC1155"; status: "UNSET" | "CREATED" | "COMPLETED" | "CANCELLED"; }}