Skip to main content

mintBatch

The mintBatch method for the ERC-1155 token standard allows for the creation of specified quantities of multiple tokens with respective IDs for a certain Ethereum address. This method is essential for scenarios that require the simultaneous minting of various token types, enhancing efficiency by consolidating multiple minting operations into a single transaction. The method is housed within the ERC1155Instance object, accessible via the designated method of the EdexaClient or a similar library.

Method Signature

async mintBatch(
userAddress: string,
ids: string[],
amounts: string[],
data: string = "0x",
signer: WalletSigner
): Promise<TransactionResponse>

Parameters

ParameterTypeDescription
userAddressstringThe Ethereum address designated to receive the minted tokens.
idsstring[]An array of specific IDs of the ERC-1155 tokens to be minted.
amountsstring[]An array indicating the quantity of each token to be minted, corresponding to the provided IDs.
datastringOptional additional data or bytes to accompany the minting function; defaults to "0x".
signerWalletSignerThe wallet signer instance tasked with signing the transaction.

Returns

  • A Promise resolving to a TransactionResponse, which offers details about the batch minting transaction.

Usage Example

First, instantiate the desired ERC-1155 token contract:

const erc1155 = edexaClient.getERC1155Instance("your ERC-1155 contract address here");

Subsequently, invoke the mintBatch method with the requisite parameters:

const recipientAddress = "0x2c360D20cE6b3D8b466511eF093C9177c3817B94";
const tokenIds = ["token-id-1", "token-id-2", "token-id-3"];
const mintAmounts = ["100", "200", "150"];
const dataBytes = "0x"; // Optional data bytes
const signer = edexaClient.createWalletSigner("your private key");

const batchMintTransaction = await erc1155.mintBatch(recipientAddress, tokenIds, mintAmounts, dataBytes, signer);
console.log(`Batch Mint Transaction Hash: ${batchMintTransaction.hash}`);

Notes

  • The mintBatch method simplifies the process of minting multiple ERC-1155 tokens simultaneously. It's crucial to ensure appropriate permissions and checks when using this method, as unrestricted batch minting can introduce potential vulnerabilities.

  • Before invoking the mintBatch method, always confirm the correctness of the Ethereum address, token IDs, and other parameters to avoid inadvertent mistakes.