Skip to main content

useCreateAuctionListing

Hook for creating an auction listing on a smart contract.

Available to use on smart contracts that implement the Marketplace or MarketplaceV3 standard.

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

Usage

Provide your Marketplace contract as the argument.

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

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

function App() {
const { contract } = useContract(contractAddress);
const { mutateAsync: createAuctionListing, isLoading, data, error } = useCreateAuctionListing(
contract
);

if (error) {
console.error("failed to create auction listing", error);
}

return (
<Web3Button
contractAddress={contractAddress}
action={() =>
createAuctionListing({
tokenId: "{{token_id}}",
assetContractAddress: "{{asset_contract_address}}",
minimumBidAmount: "{{minimum_bid_amount}}",
buyoutBidAmount: "{{buyout_bid_amount}}",
startTimestamp: new Date(),
endTimestamp: new Date(Date.now() + 60 * 60 * 24 * 7), // 7 days
})
}
>
Create Auction Listing
</Web3Button>
);
}

Configuration

startTimestamp

The starting timestamp of the auction.

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

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

function App() {
const { contract } = useContract(contractAddress);
const { mutateAsync: createAuctionListing, isLoading, data, error } = useCreateAuctionListing(
contract
);

if (error) {
console.error("failed to create auction listing", error);
}

return (
<Web3Button
contractAddress={contractAddress}
action={() =>
createAuctionListing({
tokenId: "{{token_id}}",
assetContractAddress: "{{asset_contract_address}}",
minimumBidAmount: "{{minimum_bid_amount}}",
buyoutBidAmount: "{{buyout_bid_amount}}",
startTimestamp: new Date(),
endTimestamp: new Date(Date.now() + 60 * 60 * 24 * 7), // 7 days
})
}
>
Create Auction Listing
</Web3Button>
);
}

endTimestamp

The ending timestamp of the auction.

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

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

function App() {
const { contract } = useContract(contractAddress);
const { mutateAsync: createAuctionListing, isLoading, data, error } = useCreateAuctionListing(
contract
);

if (error) {
console.error("failed to create auction listing", error);
}

return (
<Web3Button
contractAddress={contractAddress}
action={() =>
createAuctionListing({
tokenId: "{{token_id}}",
assetContractAddress: "{{asset_contract_address}}",
minimumBidAmount: "{{minimum_bid_amount}}",
buyoutBidAmount: "{{buyout_bid_amount}}",
startTimestamp: new Date(),
endTimestamp: new Date(Date.now() + 60 * 60 * 24 * 7), // 7 days
})
}
>
Create Auction Listing
</Web3Button>
);
}