Skip to main content

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 { myCollection } from "./deploy";

const myNFT = new NFT({
collection: myCollection,
metadata: {
name: "My new NFT",
description: "Probably nothing.",
creator: "Holograph Protocol",
},
ipfsInfo: {
ipfsImageCid: "QmfPiMDcWQNPmJpZ1MKicVQzoo42Jgb2fYFH7PemhXkM32",
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. Mint Multichain Open Edition (MOE)

Multichain open editions enable users to mint NFTs on multiple chains. They are created by deploying drop contracts.

src/holograph/moe-mint.ts
import { MoeNFT } from "@holographxyz/sdk";
import { networks } from "@holographxyz/networks";

import { myMOEContract } from "./moe-deploy";

const myMoeNFT = new MoeNFT({
collection: myMOEContract,
metadata: {
name: "My new MOE",
description: "Probably nothing.",
creator: "Holograph Protocol",
},
ipfsInfo: {
ipfsImageCid: "QmfPiMDcWQNPmJpZ1MKicVQzoo42Jgb2fYFH7PemhXkM32",
ipfsMetadataCid:
"QmfPiMDcWQNPmJpZ1MKicVQzoo42Jgb2fYFH7PemhXkM32/metadata.json",
},
});

const { tokenId, txHash } = await myMoeNFT.mint({
chainId: networks.polygon.chain,
quantity: 10,
});

For more information, check out the MoeNFT 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";

import { holographConfig } from "./config";

const anotherAccount = HolographAccountFactory.createAccountUsingPrivateKey(
process.env.ANOTHER_PRIVATE_KEY
);

const anotherWallet = new HolographWallet({
account: anotherAccount,
chainsRpc: holographConfig.networks,
});

const { tokenId, txHash } = await myNFT.mint(
{
chainId: networks.polygon.chain,
wallet: anotherWallet,
},
{ gasLimit: BigInt(1000) }
);