Minting on Node.js

Load a CLI generated key and mint assets on Node.js

In this guide, we will be minting some assets with AppWallet on Node.js.

System setup

1. Visual Studio Code

Visual Studio Code is a code editor made by Microsoft. Download and install Visual Studio Code for code editing.

2. Node.js

Node.js is a cross-platform JavaScript runtime environment that runs on the V8 engine and executes JavaScript code. Install the Long-Term Support (LTS) version of Node.js (as of writing v16.16.0).

Project setup

Firstly, create a new folder, and initialize a Node.js project:

npm init

Next, install the typescript and Mesh package:

npm install --dev typescript && npm install @meshsdk/core

Then, initialize Typescript which is require to compile a TypeScript:

npx tsc --init

After that, open the tsconfig.json file and define the following configurations:

  "target": "ESNext",
  "module": "ESNext",
  "moduleResolution": "Node",
  "outDir": "dist",

Finally, open the package.json file add the following configurations:

  "type": "module",
  "scripts": {
    "start": "tsc && node ./dist/main.js"

Build the minting transaction

1. Create list of NFT's metadata

Create a file named metadata.ts and define the metadata for our NFTs:

export const metadata: { [assetName: string]: any } = {
  MeshToken01: {
    name: "Mesh Token 1",
    image: "ipfs://QmRzicpReutwCkM6aotuKjErFCUD213DpwPq6ByuzMJaua",
    mediaType: "image/jpg",
    description: "Just a purple coin.",
    artist: "This NFT was minted by Mesh (",
  MeshToken02: {
    name: "Mesh Token 2",
    image: "ipfs://QmRzicpReutwCkM6aotuKjErFCUD213DpwPq6ByuzMJaua",
    mediaType: "image/jpg",
    description: "This is suppose to be a gold coin.",
    artist: "This NFT was minted by Mesh (",
  MeshToken03: {
    name: "Mesh Token 3",
    image: "ipfs://QmRzicpReutwCkM6aotuKjErFCUD213DpwPq6ByuzMJaua",
    mediaType: "image/jpg",
    description: "A coin with a M on it.",
    artist: "This NFT was minted by Mesh (",

2. Create a list of recipients

Create a file named recipients.ts and specify the list of recipients:

export const recipients: { [recipient: string]: string } = {

3. Create main.ts and import the packages:

Lets create a file named main.ts and import the packages we need and the files we have created:

import {
} from '@meshsdk/core';
import type { Mint, AssetMetadata } from '@meshsdk/core';

import { metadata } from './metadata.js';
import { recipients } from './recipients.js';

4. Define variables

Next, lets define some variables we will need for minting. You should be using your own wallet if you want to mint a collection of your own. For this example, these are the variables we need:

const demoCLIKey = {
const networkId = 0;
const blockfrostKey = 'BLOCKFROST_KEY_HERE';

5. Build the minting transaction

In this guide, we are building a minting transaction, but it could be any transactions. Learn more about Transaction.

Firstly, we need a blockchain provider, in this guide, we will import BlockfrostProvider, but you can use other providers as well:

const blockchainProvider = new BlockfrostProvider(blockfrostKey);

Next, lets initialize the AppWallet and its forging script. In this example, we initialize using CLI generated keys, but you can also load your wallet with private key and mnemonic phrases. Learn more about AppWallet.

const wallet = new AppWallet({
  networkId: networkId,
  fetcher: blockchainProvider,
  submitter: blockchainProvider,
  key: {
    type: 'cli',
    payment: demoCLIKey.paymentSkey,
    stake: demoCLIKey.stakeSkey,

const walletAddress = wallet.getPaymentAddress();
const forgingScript = ForgeScript.withOneSignature(walletAddress);

Then, lets create a new Transaction, loop through each recipient, and mint an assets with mintAsset (Learn more about minting transactions):

const tx = new Transaction({ initiator: wallet });
for (let recipient in recipients) {
  const recipientAddress = recipient;
  const assetName = recipients[recipient];
  const assetMetadata: AssetMetadata = metadata[assetName];
  const asset: Mint = {
    assetName: assetName,
    assetQuantity: '1',
    metadata: assetMetadata,
    label: '721',
    recipient: recipientAddress
  tx.mintAsset(forgingScript, asset);

Finally, lets sign and submit the transaction:

const unsignedTx = await;
const signedTx = await wallet.signTx(unsignedTx, false);
const txHash = await wallet.submitTx(signedTx);

To execute the script, run the following on your Terminal:

npm start

For a successful transaction, you should get a transaction hash, you should have minted multiple assets in a single transaction, and sent them to multiple recipients.