Skip to main content

useCancelEnglishAuction

Hook for canceling an english auction on a MarketplaceV3 contract.

Note: English auctions cannot be canceled if a bid has been placed.

Marketplace V3

Note: This hook is only for Marketplace V3 contracts.

For Marketplace contracts, use useCancelListing instead.

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

Usage

Provide your marketplace v3 contract as the argument.

Then, provide the ID of the listing you want to cancel to the mutation.

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

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

// The ID of the listing you want to cancel
const listingId = "{{listing_id}}";

function App() {
const { contract } = useContract(contractAddress, "marketplace-v3");
const {
mutateAsync: cancelEnglishAuction,
isLoading,
error,
} = useCancelEnglishAuction(contract);

return (
<Web3Button
contractAddress={contractAddress}
action={() => cancelEnglishAuction(listingId)}
>
Cancel English Auction
</Web3Button>
);
}

Configuration

listingId (required)

The ID of the listing you want to cancel.

Will populate the error property if the listing is not active, cannot be canceled, or was not created by the wallet.

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

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

// The ID of the listing you want to cancel
const listingId = "{{listing_id}}";

function App() {
const { contract } = useContract(contractAddress, "marketplace-v3");
const {
mutateAsync: cancelEnglishAuction,
isLoading,
error,
} = useCancelEnglishAuction(contract);

return (
<Web3Button
contractAddress={contractAddress}
action={() =>
cancelEnglishAuction(
listingId,
)
}
>
Cancel English Auction
</Web3Button>
);
}