useCancelDirectListing
Hook for canceling an existing auction or listing on a marketplace contract.
Note: Auction listings cannot be canceled if a bid has been placed.
import { useCancelListing } from "@thirdweb-dev/react";
Usage
Provide your marketplace contract as the argument.
import { useCancelListing, useContract, Web3Button } from "@thirdweb-dev/react";
import { ListingType } from "@thirdweb-dev/sdk";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress, "marketplace");
const {
mutateAsync: cancelListing,
isLoading,
error,
} = useCancelListing(contract);
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
cancelListing({
id: "{{listing_id}}",
type: ListingType.Direct, // Direct or Auction
})
}
>
Cancel Listing
</Web3Button>
);
}