Skip to main content

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.

import { useExecuteAuctionSale } from "@thirdweb-dev/react";

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

Usage

Provide your Marketplace contract as the argument to the hook.

Then, provide the listingId of the auction you want to execute the sale on to the mutation.

import {
useExecuteAuctionSale,
useContract,
Web3Button,
} from "@thirdweb-dev/react";

// Your smart contract address
const contractAddress = "{{contract_address}}";

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>
);
}

Configuration

listingId

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.

import {
useExecuteAuctionSale,
useContract,
Web3Button,
} from "@thirdweb-dev/react";

// Your smart contract address
const contractAddress = "{{contract_address}}";

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>
);
}