useCreateAuctionListing
Hook for creating an auction listing on a Marketplace or MarketplaceV3 smart contract.
Auction listings hold the NFTs in escrow; requiring the seller to transfer the NFTs to the marketplace contract as part of the listing creation process.
import { useCreateAuctionListing } from "@thirdweb-dev/react";
const { mutateAsync, isLoading, error } = useCreateAuctionListing(contract);
Usage
Provide your Marketplace or MarketplaceV3 contract as the argument to the hook.
Then, provide the information about the listing you want to create as the argument to the mutation.
import {
useCreateAuctionListing,
useContract,
Web3Button,
} from "@thirdweb-dev/react";
import { NATIVE_TOKEN_ADDRESS } from "@thirdweb-dev/sdk";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress, "marketplace-v3");
const {
mutateAsync: createAuctionListing,
isLoading,
error,
} = useCreateAuctionListing(contract);
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
createAuctionListing({
tokenId: "{{token_id}}", // The ID of the token to list.
assetContractAddress: "{{asset_contract_address}}", // The contract address of the asset being listed.
currencyContractAddress: NATIVE_TOKEN_ADDRESS, // The address of the currency to accept for the listing.
quantity: "{{quantity}}",
startTimestamp: new Date(),
buyoutBidAmount: "{{buyout_bid_amount}}",
minimumBidAmount: "{{minimum_bid_amount}}",
endTimestamp: new Date(),
bidBufferBps: "{{bid_buffer_bps}}",
timeBufferInSeconds: "{{time_buffer_in_seconds}}",
})
}
>
Create Auction Listing
</Web3Button>
);
}