useMakeBid
Hook for placing a bid on a marketplace listing.
import { useMakeBid } from "@thirdweb-dev/react";
Usage
Provide your Marketplace contract as the argument.
import { useMakeBid, useContract, Web3Button } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress);
const { mutateAsync: makeBid, isLoading, error } = useMakeBid(contract);
if (error) {
console.error("failed to make bid", error);
}
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
makeBid({
listingId: "1234567890",
bid: "1.00 ether",
})
}
>
Make Bid
</Web3Button>
);
}
Configuration
listingId
The id of the listing you are placing the bid on.
bid
The amount you are bidding in wei.
You can use the useBalance
hook to get this value.
import {
useMakeBid,
useContract,
Web3Button,
useBalance,
} from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const balance = useBalance();
const { contract } = useContract(contractAddress);
const { mutateAsync: makeBid, isLoading, error } = useMakeBid(contract);
if (error) {
console.error("failed to make bid", error);
}
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
makeBid({
listingId: "1234567890",
bid: balance, // Use useBalance hook to get current wallet balance
})
}
>
Make Bid
</Web3Button>
);
}