useSetClaimConditions
Hook for setting claim conditions on a drop contract.
Available for contracts that implement the claim conditions interface; such as NFT Drop, Edition Drop, and Token Drop.
import { useSetClaimConditions } from "@thirdweb-dev/react";
const { mutateAsync, isLoading, error } = useSetClaimConditions(contract);
Usage
Provide your drop contract instance as the argument.
When using an ERC1155 contract, you must also provide the token ID of the NFT you want to set claim conditions on as the second parameter to the hook.
import {
useSetClaimConditions,
useContract,
Web3Button,
} from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress);
const {
mutateAsync: setClaimConditions,
isLoading,
error,
} = useSetClaimConditions(contract);
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
setClaimConditions({
phases: [
{
metadata: {
name: "Phase 1", // The name of the phase
},
currencyAddress: "0x...", // The address of the currency you want users to pay in
price: 1, // The price of the token in the currency specified above
maxClaimablePerWallet: 1, // The maximum number of tokens a wallet can claim
maxClaimableSupply: 100, // The total number of tokens that can be claimed in this phase
startTime: new Date(), // When the phase starts (i.e. when users can start claiming tokens)
waitInSeconds: 60 * 60 * 24 * 7, // The period of time users must wait between repeat claims
snapshot: [
{
address: "0x...", // The address of the wallet
currencyAddress: "0x...", // Override the currency address this wallet pays in
maxClaimable: 5, // Override the maximum number of tokens this wallet can claim
price: 0.5, // Override the price this wallet pays
},
],
merkleRootHash: "0x...", // The merkle root hash of the snapshot
},
],
})
}
>
Set Claim Conditions
</Web3Button>
);
}
Configuration
The function takes in two arguments:
reset
- A boolean that determines whether to reset the claim conditions. This means you reset any previous claim conditions that existed and allow users to claim again as if the drop had just started.phases
- An array of claim phases that occur in chronological order. You can only have one phase occur at a time. All properties of a phase are optional, with the default being a free, open, unlimited claim, in the native currency, starting immediately.
reset (optional)
A boolean value that determines whether to reset the claim conditions or to keep the existing state.
By resetting them, any previous claims that were made will be ignored by the claim condition restrictions.
For example, if you had a limit of 1 token per wallet, and a user claimed a token, then you reset the claim conditions, that user will be able to claim another token.
Default value is false
.
phases (required)
Provide an array of phases that occur in chronological order.
Below, each property of a phase is described. Each property is optional.