Mint Queue ERC721
- Learn how to mint the large number of ERC721 Assets on Myria.
- The Mint Queue is recommended for use if you plan to mint with a big batch number of NFTs, about more than 10 assets.
- To inspect the function in the SDK with details payload and response format you can reference SDK Docs.
Prerequisites
1. Technical requirements:
2. Business criteria:
- Create a project through Myria TS SDK or Developer Portal
- Create a collection through Myria TS SDK or Developer Portal
Minting Multiple Assets
Implementation
You can create a new ERC721 mint transaction as follows:
Open a Typescript project created here
Create the
create-bulk-erc721-mint-transaction-async.ts
file in the above project and paste this code:
- Typescript
import {
BulkMintQueueAsyncParams,
BulkMintQueueAsyncResponseData,
EnvTypes,
FeeType,
MintAssetErc721InfoAsync,
MintedAssetResponse,
MintingManager,
} from "myria-core-sdk";
import { v4 as uuid } from "uuid";
const fs = require("fs");
const path = require("path");
import config from "../config";
(async () => {
const mintingManager: MintingManager = new MintingManager(EnvTypes.STAGING);
const feePercentage = 2;
const startTokenId = 123;
const endTokenId = 125;
const requestId: string = uuid();
const partnerRefId: string = String(config.project_id); // Project Id
const groupRequestId: string = requestId;
const requestDescription: string = "Description request"; //Whatever string
const accountId: string = config.accountId;
const collectionId: number = Number(config.collectionId); // Can retrieve collection ID in the Developer Portal Page
const isSupportGetBulkMetadata = true;
const royaltyRecipient: string = config.public_key;
const apiKey = config.apiKey; // Can retrieve the API key in the Developer Portal page
let assetsToMintAsync = [];
console.log("Preparing assets to mint...");
for (let i = startTokenId; i <= endTokenId; i++) {
const asset: MintAssetErc721InfoAsync = {
tokenId: String(i),
description: "mry asset", // It automatically gets description for specific assets in case if metadata url of the assets has defined description already
fees: [
{
percentage: feePercentage,
receiptAddress: royaltyRecipient,
feeType: FeeType.ROYALTY,
},
],
mintForStarkKey: "",// Your NFTs receivers/players - Define stark key of your recipients
trackingId: "123", //Whatever string that Partner/Developer wants to add for minted assets
};
assetsToMintAsync.push(asset);
}
console.log(assetsToMintAsync);
const params: BulkMintQueueAsyncParams = {
apiKey,
requestId,
partnerRefId,
groupRequestId,
requestDescription,
accountId,
collectionId,
assets: assetsToMintAsync,
isSupportGetBulkMetadata,
fees: [
{
percentage: feePercentage,
receiptAddress: royaltyRecipient,
feeType: FeeType.ROYALTY,
},
],
};
console.log("Initiating a bulk minting...");
try {
const mintAsyncResult: BulkMintQueueAsyncResponseData =
await mintingManager.bulkMintNftsQueueAsync(params);
console.log("Bulk minting is completed. Result: ", mintAsyncResult);
} catch (error) {
console.log("Mint failed: ", error);
}
})();
Replace the parameter
object values as follows:
API_KEY
- Api Key, retrieved in the Developer Portal page, where you're able to generate in the Settings tab of the Developer Portal pageCOLLECTION_ID
- Sequence ID of the collection - you can retrieve via the Developer Portal PageREQUEST_DESCRIPTION
- The description to specify any highlight for those NFTs groups - You can put whatever you'd requery and keep track in post mintingGROUP_REQUEST_ID
- The group request ID is used to requery the list of assets have been minted queue asynchronously - Required to be passed as UUID formatPARTNER_REF_ID
- Your project ID - where you should be able to re-query the list of minted transactions along with groupRequestID to check the minting statusACCOUNT_ID
- Myria User ID Can be retrieved on the Settings tab of the Developer Portal page and it is Myria User IDTOKEN_ID
- unique identifier of a given asset, should be an incremental numeric value starting from 1DESCRIPTION
- description of a given assetROYALTY_PERCENTAGE
- royalty percentage a wallet would receive from secondary salesROYALTY_RECIPIENT_ADDRESS
- wallet address of royalty recipientIS_SUPPORT_GET_BULK_METADATA
- This field is default set to false, only enable it to true if your metadata URL has support to get the batch metadata as this format:metadataUrl?tokenIds=1,2,3,4,5,6....
- Add a script to load the
create-bulk-erc721-mint-transaction-async.ts
file inpackage.json
:
{
"scripts": {
"create-project": "ts-node create-project.ts",
"create-collection": "ts-node create-collection.ts",
"create-bulk-erc721-mint-transaction-async": "ts-node create-bulk-erc721-mint-transaction-async.ts" },
}
- Run the
create-bulk-erc721-mint-transaction-async
script:
npm run create-erc721-mint-transaction-async
After a mint transaction is created, you will see the response that looks as follows: BulkMintQueueAsyncResponseData
Once you've triggered the mint transaction request, all minted requests will be put into the Queue in Myria System and it is going to be processed asynchronously, the waiting time for assets to be transitioned from state MINTING to state MINTED could be dependent on how large of the batch size.
For example (below are just small, assumed estimations and might not be precise in 100%):
- 100 assets / request -> 10 minutes.
- 50 assets / request -> 5 minutes.
You can use the following method Query transactions by groupRequestId and partnerRefId to get the list of minted transactions according to transaction status and know if the assets are ready on the Marketplace for trading.
Transaction status:
Prepare
: The minted transactions are in the waiting queue.Pending
: The minted transactions have been processed in Myria L2 and synchronized to Starkware - Assets are ready for use and trading/listing once the transaction is at Pending status.Success
: Starkware confirmed that the transaction is validated, and the state is kept tracked between Myria and Starkware system for newly minted assets.
Royalties
Note that the royalty field is an optional parameter and you only need to specify it once you have a plan for the percentage of the fee in the Royalty in every trading transaction.
For more details, you can reference the SDK DOCS.
Next steps
Now that you minted your first ERC721 asset, you can list it on the Myria NFT Marketplace.