useMakeOffer
Hook for placing an offer on a Marketplace direct listing.
import { useMakeOffer } from "@thirdweb-dev/react";
const { mutateAsync, isLoading, error } = useMakeOffer(contract);
Usage
Provide your Marketplace contract instance from the useContract
hook as the argument.
Then, provide the listingId
, pricePerToken
, and quantity
to the mutation.
import { useMakeOffer, useContract, Web3Button } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
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>
);
}