Skip to content

Getting mint costs

The Collector Client provides a way get the costs to mint x quantities of an 1155s, 721s, or premints. This is done by getting a token item using the getMintable() function, calling prepareMint() with the quantity to mint, and using the returned cost object to get the costs to mint x quantity of the token.

example.ts
import { usePublicClient, useAccount } from "wagmi";
import { createCollectorClient } from "@zoralabs/protocol-sdk";
import { chainId, publicClient } from "./config";
import { tokenAddress, tokenId } from "./data";
 
const publicClient = usePublicClient();
 
const collectorClient = createCollectorClient({ chainId, publicClient });
const { address } = useAccount();
 
const { prepareMint } = await collectorClient.getToken({
  // 1155 contract address
  collection: tokenAddress,
  // 1155 token id
  tokenId,
  mintType: "
1155
721
premint
",
}); // get the costs by calling the returned `prepareMint` function // with the quantity to mint const { costs } = prepareMint({ minterAccount: address!, quantityToMint: 3n }); costs.
mintFee
totalCostEth
totalPurchaseCost
totalPurchaseCostCurrency