useBuyNow() function
This feature is currently in beta and may change based on feedback that we receive.
Use this to buy out an auction listing from your marketplace contract.
Example
const Component = () => {
const {
mutate: buyNow,
isLoading,
error,
} = useBuyNow(">>YourMarketplaceContractInstance<<");
if (error) {
console.error("failed to buyout listing", error);
}
return (
<button
disabled={isLoading}
onClick={() => buyNow({ listingId: 1, type: ListingType.Auction })}
>
Buy listing!
</button>
);
};
Signature:
export declare function useBuyNow(
contract: RequiredParam<Marketplace>,
): import("@tanstack/react-query").UseMutationResult<
Omit<
{
receipt: import("@ethersproject/abstract-provider").TransactionReceipt;
data: () => Promise<unknown>;
},
"data"
>,
unknown,
| {
id: BigNumberish;
type: ListingType.Direct;
buyAmount: BigNumberish;
buyForWallet?: string | undefined;
}
| {
id: BigNumberish;
type: ListingType.Auction;
},
unknown
>;
Parameters
Parameter | Type | Description |
---|---|---|
contract | RequiredParam<Marketplace> | an instance of a Marketplace contract |
Returns:
import("@tanstack/react-query").UseMutationResult<Omit<{ receipt: import("@ethersproject/abstract-provider").TransactionReceipt; data: () => Promise<unknown>; }, "data">, unknown, { id: BigNumberish; type: ListingType.Direct; buyAmount: BigNumberish; buyForWallet?: string | undefined; } | { id: BigNumberish; type: ListingType.Auction; }, unknown>
a mutation object that can be used to buy out an auction listing