Skip to main content

Mint ERC721 Assets

Learn how to mint an ERC721 Assets on Myria.




You can find the full implementation of this code sample in the myria-ts-samples repository.

You can create a new ERC721 mint transaction as follows:

  1. Open a Typescript project created here

  2. Create the create-erc721-mint-transaction.ts file in the above project and paste this code:

import { MintingManager, MintERC721Params, MintERC721Response, FeeType, EnvTypes } from "myria-core-sdk";

(async (): Promise<void> => {

// define the environment: STAGING or PRODUCTION
const env = EnvTypes.STAGING;

// get access to the `MintingManager`
const mintingManager: MintingManager = new MintingManager(env);

// define parameters for mint transaction
const params: MintERC721Params = {
starkKey: "STARK_KEY",
contractAddress: "CONTRACT_ADDRESS",
uri: "TOKEN_URI",
tokenId: "TOKEN_ID",
description: "DESCRIPTION",
fees: [
feeType: FeeType.ROYALTY

// create a mint transaction
const mintTransactionResponse: MintERC721Response | undefined =
await mintingManager.createMintTransactionERC721(params);

// log the result
console.log(JSON.stringify(mintTransactionResponse, null, 2));

Replace the params object values as follows:

  • STARK_KEY - Stark Key, has to start with 0x
  • CONTRACT_ADDRESS - contract address used to withdraw assets to the Ethereum network
  • TOKEN_URI - URL path to the mintable asset metadata
  • TOKEN_ID - unique identifier of a given asset, should be an incremental numeric value starting from 1
  • DESCRIPTION - description of a given asset
  • ROYALTY_PERCENTAGE - royalty percentage a wallet would receive from secondary sales
  • ROYALTY_RECIPIENT_ADDRESS - wallet address of royalty recipient
  • Use a maximum of 2 decimal places in the ROYALTY_PERCENTAGE. Setting ROYALTY_PERCENTAGE to 2.5 means the royalty paid out will be 2.5% of the sale price.
  • The default value for the ROYALTY_RECIPIENT_ADDRESS is the collection creator address.

Make sure there is no trailing / at the end of the TOKEN_URI or you won't be able to mint assets.

  1. Add a script to load the create-erc721-mint-transaction.ts file in package.json:
"scripts": {
"create-project": "ts-node create-project.ts",
"create-collection": "ts-node create-collection.ts",
"create-erc721-mint-transaction": "ts-node create-erc721-mint-transaction.ts"
  1. Run the create-erc721-mint-transaction script:
npm run create-erc721-mint-transaction

After a mint transaction is created, you will see the response that looks as follows:

"asset": {
"uri": "",
"starkKey": "0x7fe1b18d74145afd74c0b84b693c9e8eb4de49a3972743f4cd2fbfc3904e9cb",
"assetType": "MINTABLE_ERC721",
"tokenId": "1",
"tokenAddress": "0x3bb911f179f34aac30ef4e175f57dedf49312cb7",
"status": "MINTED",
"description": "Asset X",
"collectionId": 39,
"creatorStarkKey": "0x7fe1b18d74145afd74c0b84b693c9e8eb4de49a3972743f4cd2fbfc3904e9cb",
"updatedAt": "2022-08-17T04:11:27.763Z",
"name": "mto1",
"imageUrl": null,
"animationUrl": null,
"animationUrlMimeType": null,
"assetMintId": "0x400d7f08c2bd93fded45000d55f20a1eb52a8d90c6912a1315533179219937c",
"transactionId": 39026,
"id": 26149,
"createdAt": "2022-08-17T04:11:26.013Z",
"metadata": {},
"metadataOptional": {
"description": "MT Original 1",
"externalUrl": "",
"image": "",
"attributes": [
"trait_type": "Category",
"value": "Silver"
"trait_type": "Edition",
"value": 1
"trait_type": "Level",
"value": 1
"publicId": "74eab8f4-b68d-410c-a8f6-513a05b2d135"
"transaction": {
"tokenType": "MINTABLE_ERC721",
"vaultId": 54424,
"quantizedAmount": "1",
"starkKey": "0x7fe1b18d74145afd74c0b84b693c9e8eb4de49a3972743f4cd2fbfc3904e9cb",
"transactionCategory": "MintRequest#0x3bb911f179f34aac30ef4e175f57dedf49312cb7#1",
"transactionId": 39026,
"transactionType": "MintRequest",
"transactionStatus": "Prepare",
"createdAt": 1660709487350,
"tokenAddress": "0x3bb911f179f34aac30ef4e175f57dedf49312cb7",
"assetType": "0x23d90e1e5140402f246c683dcd6c3d6876968ff03c0187eddc9c255b3a0f4c5",
"assetId": "0x400d7f08c2bd93fded45000d55f20a1eb52a8d90c6912a1315533179219937c",
"tokenId": "1",
"quantum": "1",
"blueprint": "",
"nonce": 1,
"environment": "staging"

Minting Multiple Assets

The best way to mint a large number of NFTs is to run a script, making multiple calls. This does not incur any fees.

A basic sample script is available here.


tokenId is a required parameter of the MintERC721Params. Not including it this will cause issues during the bulk minting process.

Next steps

Now that you minted your first ERC721 asset, you can list it on the Myria NFT Marketplace.