Skip to main content

useActiveClaimCondition

Hook for getting the active claim condition for a given drop contract.

Available for contracts that implement claim phases; such as NFT Drop, Edition Drop, and Token Drop.

import { useActiveClaimCondition } from "@thirdweb-dev/react";

Usage

Provide your drop contract as the first argument to the hook.

import { useActiveClaimCondition, useContract } from "@thirdweb-dev/react";

function App() {
// Contract can be any contract that implements claim conditions.
// Including ERC721, ERC1155, and ERC20 drop contracts.
const { contract } = useContract(contractAddress);
const { data, isLoading, error } = useActiveClaimCondition(contract);
}

Configuration

tokenId

The second parameter is the tokenId.

When using the hook with ERC1155 contracts, pass the tokenId as the second parameter; as each token can have unique claim conditions.

Pass undefined, or leave this field out if you are using ERC721 or ERC20 drop contracts.

import { useActiveClaimCondition, useContract } from "@thirdweb-dev/react";

// Your smart contract address
const contractAddress = "{{contract_address}}";

function App() {
const { contract } = useContract(contractAddress);

// "data" now includes a "snapshot" property that contains the allowlist.
const { data, isLoading, error } = useActiveClaimCondition(
contract,
0, // Token ID required for ERC1155 contracts here.
);
}

withAllowlist

By default, the hook will not include the allowlist in the returned data.

To include the allowlist in the returned data, set the withAllowlist option to true.

This will add a snapshot property to the returned data, which contains the allowlist in an array.

import { useActiveClaimCondition, useContract } from "@thirdweb-dev/react";

// Your smart contract address
const contractAddress = "{{contract_address}}";

function App() {
const { contract } = useContract(contractAddress);

// "data" now includes a "snapshot" property that contains the allowlist.
const { data, isLoading, error } = useActiveClaimCondition(
contract,
undefined, // Token ID required for ERC1155 contracts here.
{
withAllowlist: true,
},
);
}

Return Value

The hook's data property, once loaded, contains the following properties:

{
maxClaimableSupply: string;
startTime: Date;
price: BigNumber;
currencyAddress: string;
maxClaimablePerWallet: string;
waitInSeconds: BigNumber;
merkleRootHash: string | number[];
availableSupply: string;
currentMintSupply: string;
currencyMetadata: {
symbol: string;
value: BigNumber;
name: string;
decimals: number;
displayValue: string;
};
metadata?: {
[x: string]: unknown;
name?: string | undefined;
} | undefined;
snapshot?: {
price?: string | undefined;
currencyAddress?: string | undefined;
address: string;
maxClaimable: string;
}[] | null | undefined;
}