useClaimNFT
Hook for claiming an NFT from a smart contract.
Available to use on smart contracts that implement a Claimable interface, and follow either the ERC721 or ERC1155 standard.
import { useClaimNFT } from "@thirdweb-dev/react";
const { mutateAsync, isLoading, error } = useClaimNFT(contract);
Usage
Provide your drop contract (ERC721 or ERC1155) as the argument.
import { useContract, useClaimNFT, Web3Button } from "@thirdweb-dev/react";
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress);
const { mutateAsync, isLoading, error } = useClaimNFT(contract);
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
claimNft({
to: "{{wallet_address}}", // Use useAddress hook to get current wallet address
quantity: 1,
})
}
>
Claim NFT
</Web3Button>
);
}