saveSnapshot

Generate merkle tree for a given snapshot and save the info on-chain.

Example

// This is ERC20 example. Should import and use other ERC variants as needed
import { generateMerkleTreeInfoERC20, saveSnapshot, setMerkleRoot } from "thirdweb/extensions/airdrop";
// snapshot / allowlist of airdrop recipients and amounts
const snapshot = [
{ recipient: "0x...", amount: 10 },
{ recipient: "0x...", amount: 15 },
{ recipient: "0x...", amount: 20 },
];
const tokenAddress = "0x..." // Address of airdrop token
const { merkleRoot, snapshotUri } = await generateMerkleTreeInfoERC20({
contract,
tokenAddress,
snapshot
});
const saveSnapshotTransaction = saveSnapshot({
contract,
merkleRoot,
snapshotUri,
});
await sendTransaction({ saveSnapshotTransaction, account });
const setMerkleRootTransaction = setMerkleRoot({
contract,
token,
tokenMerkleRoot: merkleRoot as `0x${string}`,
resetClaimStatus: false // toggle as needed
signature,
});
await sendTransaction({ setMerkleRootTransaction, account });
function saveSnapshot(

Parameters

The transaction options.

Type

Returns

let returnType: PreparedTransaction<
any,
AbiFunction,
>;

A promise that resolves to the transaction result.