useMakeBid
Hook for placing a bid on a Marketplace auction listing.
Bids have several important properties:
- Cannot be canceled once placed.
- Are automatically refunded if they are outbid.
- Must be higher than the current highest bid by the percentage defined in the bid buffer.
- Must be higher than the reserve price (if there is no bid yet).
import { useMakeBid } from "@thirdweb-dev/react";
const { mutateAsync: makeBid, isLoading, error } = useMakeBid(contract);
Usage
Provide your Marketplace contract instance from the useContract
hook as the argument.
Then, provide the listingId
and bid
value to the mutation.
import { useMakeBid, useContract, Web3Button } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress, "marketplace");
const { mutateAsync: makeBid, isLoading, error } = useMakeBid(contract);
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
makeBid({
listingId: "1", // ID of the listing to bid on. Must be an auction.
bid: "1", // Uses the currencyContractAddress of the listing.
})
}
>
Make Bid
</Web3Button>
);
}