Class

MintingManager

MintingManager(env)

Constructor

# new MintingManager(env)

Create MintingManager module

Parameters:
Name Type Description
env EnvTypes

Environment type (DEV / STAGING / PREPROD / PROD)

View Source modules/MintingManager.ts, line 4

Example

MintingManager instantiation

  const mintingManager = new MintingManager(EnvTypes.STAGING);

Methods

# async bulkMintNfts(payload) → {BulkMintERC721ResponseData}

Processes the bulk mint for list of assets (MINTABLE_ERC721)

Parameters:
Name Type Description
payload BulkMintERC721Params

Request for bulk mint list of ERC721

View Source modules/MintingManager.ts, line 483

Exception: Stark Key is required

string

Exception: Contract address is required

string

Exception: Assets length should be greater than 0

string

Exception: (x) th asset's uri is required

string

Exception: (x) th asset's tokenId is required

string

Http Status 500: Bulk mint failed with internal server error

string

Bulk mint response data

Example

Sample function for bulkMintNfts({})

    const mintingManager: MintingManager = new MintingManager(env);

    const feePercentage = 2;
    const startTokenId = 1;
    const endTokenId = 30;

    const starkKey: string = config.stark_key;
    const contractAddress: string = config.collection_contract_address;
    const metadataApiUrl: string = config.metadata_api_url;
    const royaltyRecipient: string = config.public_key;

    let assetsToMint = [];

    console.log("Preparing assets to mint...");
    for (let i = startTokenId; i <= endTokenId; i++) {
      const asset: MintAssetErc721Info = {
        uri: `${metadataApiUrl}/${i}`,
        tokenId: String(i),
        description: 'mry asset',
        fees: [{
          percentage: feePercentage,
          receiptAddress: royaltyRecipient,
          feeType: FeeType.ROYALTY
        }]
      };
      assetsToMint.push(asset);
    }
    console.log(assetsToMint);

    const params: BulkMintERC721Params = {
      starkKey: starkKey,
      contractAddress: contractAddress,
      assets: assetsToMint,
      isSupportGetBulkMetadata: true,
      fees: [{
        percentage: feePercentage,
        receiptAddress: royaltyRecipient,
        feeType: FeeType.ROYALTY
      }]
    };

    console.log("Initiating a bulk minting...");
    const mintResult: BulkMintERC721ResponseData = await mintingManager.bulkMintNfts(params);
    console.log("Bulk minting is completed. Result: ", mintResult);

# async bulkMintNftsQueueAsync(payload) → {BulkMintQueueAsyncResponseData}

Processes the bulk mint in queue for list of NFTs flow (MINTABLE_ERC721)

Parameters:
Name Type Description
payload BulkMintQueueAsyncParams

Request params for bulk mint queue

View Source modules/MintingManager.ts, line 562

Exception: apiKey is required

string

Exception: RequestId is required

string

Exception: PartnerRefId is required

string

Exception: GroupRequestId is required

string

Exception: RequestDescription is required

string

Exception: AccountId is required

string

Exception: CollectionId is required

string

Exception: Assets length should be greater than 0

string

Exception: (x) th asset's tokenId is required

string

Exception: (x) th asset's description is required

string

Exception: (x) th asset's trackingId is required

string

Exception: (x) th asset's mintForStarkKey invalid

string

Http Status 500: Bulk mint failed with internal server error

string

Bulk mint queue response data

Example

Sample function for bulkMintNftsQueueAsync({})

    const mintingManager: MintingManager = new MintingManager(env);

    const feePercentage = 2;
    const startTokenId = 1;
    const endTokenId = 30;

    const requestId: string = config.requestId;
    const partnerRefId: string = config.partnerRefId;
    const groupRequestId: string = config.groupRequestId;
    const requestDescription: string = config.requestDescription;
    const accountId: string = config.accountId;
    const apiKey: string = config.apiKey;
    const collectionId: string = config.collectionId;
    const isSupportGetBulkMetadata: boolean = config.isSupportGetBulkMetadata;
    const royaltyRecipient: string = config.royaltyRecipient;

    let assetsToMintAsync = [];

    console.log("Preparing assets to mint...");
    for (let i = startTokenId; i <= endTokenId; i++) {
      const asset: MintAssetErc721InfoAsync = {
        tokenId: String(i),
        description: 'mry asset',
        fees: [{
          percentage: feePercentage,
          receiptAddress: royaltyRecipient,
          feeType: FeeType.ROYALTY
        }],
        mintForStarkKey: '0x.....',
        trackingId: 'trackingID',
      };
      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...");
    const mintV2Result: BulkMintQueueAsyncResponseData = await mintingManager.bulkMintNftsQueueAsync(params);
    console.log("Bulk minting is completed. Result: ", mintResult);

# async createMintTransactionERC721(data) → {MintERC721Response|undefined}

Create a single NFT (MINTABLE_ERC721) through mint transaction in Myria system

Parameters:
Name Type Description
data MintERC721Params

Request params for minting ERC721

View Source modules/MintingManager.ts, line 411

Mint response data for ERC721 (including assets / transactionInformation...)

MintERC721Response | undefined
Example

Sample function for createMintTransactionERC721({})

    const mintingManager: MintingManager = new MintingManager(env);

    const starkKey = '0xabc....'; // Your registered stark key with Myria system 
    const contractAddress = '0xdf...'; // Unique smart contract address for collection
    const metadataApiUrl = 'https://metadata-example.com'; // Sample of base metadata url
    const tokenId = 1; // Your unique token ID to identify and locate the NFT asset in the storage
    
    const percentage = 10; // 10% fee for purchase transaction to return to creator
    const royaltyRecipient = '0xpad....'; // Sample wallet address of receiver (author/creator of the NFT)

    const params: MintERC721Params = {
      starkKey: starkKey,
      contractAddress: contractAddress,
      uri: `${metadataApiUrl}/${tokenId}`,
      tokenId: String(tokenId),
      description: "mry asset",
      fees: [
        {
          percentage: feePercentage,
          receiptAddress: royaltyRecipient,
          feeType: FeeType.ROYALTY
        },
      ],
    };
    const mintTransactionResponse = await mintingManager.createMintTransactionERC721(
      params
    );

# async getMintTransactionDetails(transactionId) → {GetMintedTransactionResponse}

Get transaction details for minting

Parameters:
Name Type Description
transactionId number

Unique sequence ID of transaction

View Source modules/MintingManager.ts, line 422

Exception: TransactionId is required

string

Exception: Get minted transaction details failure with error: ${serverError}

string

Details information of minted transaction