useMakeOffer

Hook for placing an offer on a Marketplace direct listing.

Example

import {
useMakeOffer,
useContract,
Web3Button,
} from "@thirdweb-dev/react";
function App() {
const { contract } = useContract(contractAddress, "marketplace");
const {
mutateAsync: makeOffer,
isLoading,
error,
} = useMakeOffer(contract);
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
makeOffer({
listingId: 1, // ID of the listing to make an offer on
pricePerToken: 1, // Price per token to offer (in the listing's currency)
quantity: 1, // Number of NFTs you want to buy (used for ERC1155 NFTs)
})
}
>
Make Bid
</Web3Button>
);
}

Parameters

Returns

Mutation object to make a bid on an auction listing

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

options

The mutation function takes an object as an argument with the following properties:

listingId (required)

The ID of the listing to make an offer on.

If the listing cannot be found, is not a direct listing, or is not active, the error property will be set.

pricePerToken (required)

The price to offer per token.

  • For ERC1155, this is the price to offer per quantity of the NFT (see quantity below).

  • For ERC721, this is the price to offer to buy the NFT.

quantity (optional)

Used for ERC1155 NFTs, where multiple quantity of the same NFT can be bought at once.

This field works with the pricePerToken field to calculate the total price of the offer. For example, if you want to buy 5 NFTs at a price of 1 ETH each, you would set pricePerToken to 1 and quantity to 5 , for a total of 5 ETH as the offer.

For ERC721 NFTs, this value is ignored and 1 is used instead.

The default value is 1 .