Skip to content

Instantly share code, notes, and snippets.

@warengonzaga
Last active May 6, 2024 01:48
Show Gist options
  • Save warengonzaga/790905e314075ab7de086d1e973180c2 to your computer and use it in GitHub Desktop.
Save warengonzaga/790905e314075ab7de086d1e973180c2 to your computer and use it in GitHub Desktop.
Set Claim Condition in Batch in thirdweb SDK v4
import { config } from "dotenv";
import { ThirdwebSDK } from "@thirdweb-dev/sdk";
config();
const main = async () => {
if (!process.env.WALLET_PRIVATE_KEY) {
throw new Error("No private key found");
}
try {
const sdk = ThirdwebSDK.fromPrivateKey(
process.env.WALLET_PRIVATE_KEY,
"mumbai",
{
secretKey: process.env.THIRDWEB_SECRET_KEY,
}
);
const contractAddress = "0x2192198298ac19F18E70F8710c08a1B180AA8aD4";
const contract = await sdk.getContract(contractAddress, "edition-drop");
const publicStartTime = new Date();
const claimConditions = [
{
metadata: {
name: "Public Phase", // The name of the phase
},
startTime: publicStartTime, // start the presale now
maxClaimableSupply: 4500, // limit how many mints for this presale
maxClaimablePerWallet: 1, // limit how many mints per wallet
currencyAddress: "0x29F8230f7e8Cff6751D80d1F083BF9F31292f7FA", // address of the currency to accept
price: 6, // price
}
];
// const txResult = await contract.erc1155.claimConditions.set(1, claimConditions);
const txResult = await contract.erc1155.claimConditions.setBatch([
{claimConditions, tokenId: 0},
{claimConditions, tokenId: 2},
{claimConditions, tokenId: 3},
{claimConditions, tokenId: 4},
{claimConditions, tokenId: 5},
]);
console.log("txResult: ", txResult);
console.log("Success!");
} catch (e) {
console.error("Something went wrong: ", e);
}
};
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment