useCancelDirectListing

Hook for canceling a direct listing on a MarketplaceV3 contract.

Direct listings can be canceled at any time, (unless the listing has already been sold). Only the creator of the listing can cancel it.

Note: This hook is only for Marketplace V3 contracts.

For Marketplace contracts, use useCancelListing instead.

Example

import {
useCancelDirectListing,
useContract,
Web3Button,
} from "@thirdweb-dev/react";
import { ListingType } from "@thirdweb-dev/sdk";
function App() {
const { contract } = useContract(contractAddress, "marketplace-v3");
const {
mutateAsync: cancelDirectListing,
isLoading,
error,
} = useCancelDirectListing(contract);
return (
<Web3Button
contractAddress={contractAddress}
action={() => cancelDirectListing(listingId)}
>
Cancel Direct Listing
</Web3Button>
);
}
function useCancelDirectListing(
contract: RequiredParam<MarketplaceV3>,
): UseMutationResult<
Omit<{}, "data">,
unknown,
BigNumberish,
unknown
>;

Parameters

Instance of a MarketplaceV3 contract

Type

let contract: RequiredParam<MarketplaceV3>;

Returns

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

Mutation object to cancel a direct listing by passing the ID of the listing you want to cancel.

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

The mutation function takes the listingId as an argument.

The error property is set if the listing is not active, or was not created by the wallet

listingId

The ID of the listing you want to cancel.