useExecuteAuctionSale

Hook for executing a sale of an auction listing on a Marketplace contract.

Triggers a new sale, transferring the NFT(s) to the buyer and the funds to the seller.

A sale must be executed when an auction ends, and the auction has a winning bid that was below the buyout price. This means the auction has finished, and the highest bidder has won the auction. Any wallet can now execute the sale, transferring the NFT(s) to the buyer and the funds to the seller.

Example

import {
useExecuteAuctionSale,
useContract,
Web3Button,
} from "@thirdweb-dev/react";
function App() {
const { contract } = useContract(contractAddress, "marketplace");
const {
mutateAsync: executeAuctionSale,
isLoading,
error,
} = useExecuteAuctionSale(contract);
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
executeAuctionSale({
// The listingId of the auction to execute
listingId: "{{listing_id}}",
})
}
>
Execute Auction Sale
</Web3Button>
);
}
function useExecuteAuctionSale(
contract: RequiredParam<Marketplace>,
): UseMutationResult<
Omit<{}, "data">,
unknown,
unknown
>;

Parameters

Instance of a Marketplace contract

Type

let contract: RequiredParam<Marketplace>;

Returns

let returnType: UseMutationResult<
Omit<{}, "data">,
unknown,
unknown
>;

Mutation object to accept an offer on a direct listing

const { mutateAsync, isLoading, error } =
useExecuteAuctionSale(contract);

options

The mutation function accepts an object as argument with the following properties:

listingId

The ID of the auction listing to execute the sale on. If the listing cannot be found, is not an auction, or is not ready to be executed, the error property will be set.