Skip to main content

useClaimConditions

Hook for fetching the claim conditions of a drop on a smart contract.

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

Usage

Provide your drop collection contract as the argument.

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

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

function App() {
const { contract } = useContract(contractAddress);
const { data: conditions, isLoading, error } = useClaimConditions(contract);

if (error) {
console.error("failed to fetch conditions", error);
}

return (
<div>
{conditions &&
conditions.map((condition) => (
<div>
Name: {condition.metadata?.name}
Start Time: {condition.startTime}
Price: {condition.price}
Currency Address: {condition.currencyAddress}
Max Claimable: {condition.maxClaimable}
</div>
))}
</div>
);
}

Configuration

tokenId

Optionally, you can provide a token id as the second argument to fetch the conditions for a specific token.

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

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

function App() {
const { contract } = useContract(contractAddress);
const { data: conditions, isLoading, error } = useClaimConditions(
contract,
"0x01"
);

if (error) {
console.error("failed to fetch conditions", error);
}

return (
<div>
{conditions &&
conditions.map((condition) => (
<div>
Name: {condition.metadata?.name}
Start Time: {condition.startTime}
Price: {condition.price}
Currency Address: {condition.currencyAddress}
Max Claimable: {condition.maxClaimable}
</div>
))}
</div>
);
}

options

Optionally, you can provide an options object as the third argument to include the allowlist when fetching the conditions.

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

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

function App() {
const { contract } = useContract(contractAddress);
const { data: conditions, isLoading, error } = useClaimConditions(
contract,
"0x01",
{ withAllowList: true }
);

if (error) {
console.error("failed to fetch conditions", error);
}

return (
<div>
{conditions &&
conditions.map((condition) => (
<div>
Name: {condition.metadata?.name}
Start Time: {condition.startTime}
Price: {condition.price}
Currency Address: {condition.currencyAddress}
Max Claimable: {condition.maxClaimable}
</div>
))}
</div>
);
}