Skip to main content

useClaimConditions

Hook for fetching all claim conditions for a given drop contract.

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

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

const { data, isLoading, error } = useClaimConditions(contract);

Usage

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

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

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

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 } = useClaimConditions(contract);
}

Configuration

tokenId (ERC1155 only)

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 { useClaimConditions, useContract } from "@thirdweb-dev/react";

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

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

const { data, isLoading, error } = useClaimConditions(
contract,
0, // Token ID required for ERC1155 contracts here.
);
}
withAllowlist (optional)

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 { useClaimConditions, 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 } = useClaimConditions(
contract,
undefined, // Token ID required for ERC1155 contracts here.
{
withAllowlist: true,
},
);
}

Return Value

Return Value

The hook's data property, once loaded, contains an array of objects with 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;
}