Minting Tokens
Learn how to mint tokens on multiple chains with Holograph SDK.
Prerequisites
To get the most out of this guide, make sure to:
1. Mint NFT
src/holograph/mint.ts
import { NFT } from "@holographxyz/sdk";
import { networks } from "@holographxyz/networks";
import { myContract } from "./deploy";
const myNFT = new NFT({
contract: myContract,
ipfsMetadataCid: "QmfPiMDcWQNPmJpZ1MKicVQzoo42Jgb2fYFH7PemhXkM32/metadata.json"
});
const { tokenId, txHash } = await myNFT.mint({
chainId: networks.polygon.chain,
});
For more information, check out the NFT class reference.
Congrats! You have minted an NFT with Holograph SDK!
2. Purchase Multichain Open Edition (MOE)
Multichain open editions enable users to purchase NFTs on multiple chains. They are created by deploying drop contracts.
src/holograph/open-edition-purchase.ts
import { OpenEditionNFT } from "@holographxyz/sdk";
import { networks } from "@holographxyz/networks";
import { myOpenEditionContract } from "./open-edition-deploy";
const myOpenEditionNFT = new OpenEditionNFT({
contract: myOpenEditionContract,
});
const { tokenId, txHash } = await myOpenEditionNFT.purchase({
chainId: networks.polygon.chain,
quantity: 10,
});
For more information, check out the OpenEditionNFT class reference.
3. Mint NFT with Different Wallets
Mint NFTs using different wallets by passing the wallet object as a parameter to the mint method. There is support for the config overrides such as gas
, gasLimit
, and more within the options
param. Check out the full list of options in the NFT class reference.
src/holograph/mint.ts
import { HolographAccountFactory, HolographWallet } from "@holographxyz/sdk";
import { networks } from "@holographxyz/networks";
const anotherAccount = HolographAccountFactory.createAccountUsingPrivateKey(
process.env.ANOTHER_PRIVATE_KEY
);
const anotherWallet = new HolographWallet({
account: anotherAccount,
});
const { tokenId, txHash } = await myNFT.mint(
{
chainId: networks.polygon.chain,
wallet: anotherWallet,
},
{ gasLimit: BigInt(1000) } // Optional config overrides.
);