useClaimIneligibilityReasons
Hook for fetching the reasons a wallet is not eligible to claim tokens from a drop, if any.
Available for contracts that implement the claim conditions interface; such as NFT Drop, Edition Drop, and Token Drop.
import { useClaimIneligibilityReasons } from "@thirdweb-dev/react";
Usage
Provide your Drop contract as the argument.
import { useClaimIneligibilityReasons, useContract } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress);
const { data, isLoading, error } = useClaimIneligibilityReasons(contract, {
walletAddress: "{{wallet_address}}", // Use useAddress hook to get the user's wallet address
quantity: 1, // Quantity to check eligibility for
});
}
Configuration
eligibilityParams (required)
The conditions to check eligibility for. The walletAddress
and quantity
properties are required.
Use the useaddress
hook to get the connected wallet address.
import { useClaimIneligibilityReasons, useContract } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress);
const address = useAddress();
const { data, isLoading, error } = useClaimIneligibilityReasons(
contract,
{
walletAddress: address || "",
quantity: 1,
},
);
}
tokenId (ERC1155)
When using ERC1155 contracts, provide a third argument to specify the token ID.
import { useClaimIneligibilityReasons, useContract } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
const tokenId = 1;
function App() {
const { contract } = useContract(contractAddress);
const { data, isLoading, error } = useClaimIneligibilityReasons(
contract,
{
walletAddress: "{{wallet_address}}",
quantity: 1,
},
tokenId,
);
}
Return Value
The hook's data
property, once loaded, contains an array of ClaimEligibility
strings, which may be empty.
For example, if the user is not in the allowlist, this hook will return ["This address is not on the allowlist."]
.
If the user is eligible to claim tokens, the hook will return an empty array.
ClaimEligibility[]
// ClaimEligibility Enum
export enum ClaimEligibility {
NotEnoughSupply = "There is not enough supply to claim.",
AddressNotAllowed = "This address is not on the allowlist.",
WaitBeforeNextClaimTransaction = "Not enough time since last claim transaction. Please wait.",
AlreadyClaimed = "You have already claimed the token.",
NotEnoughTokens = "There are not enough tokens in the wallet to pay for the claim.",
NoActiveClaimPhase = "There is no active claim phase at the moment. Please check back in later.",
NoClaimConditionSet = "There is no claim condition set.",
NoWallet = "No wallet connected.",
Unknown = "No claim conditions found.",
}