Mint New Carbon NFT

To mint a new Carbon NFT, you first need to obtain both the Carbon token ID and the Carbon token series ID. These identifiers are returned from the token creation transaction and series creation transaction, respectively.

Minting a New Carbon NFT

The following code snippet demonstrates how to mint a new Carbon NFT.

Imports

These are the imports typically required for minting a Carbon NFT:

import {
  Bytes32,
  getRandomPhantasmaId,
  MintNftFeeOptions,
  MintNonFungibleTxHelper,
  NftRomBuilder,
  PhantasmaAPI,
  PhantasmaKeys,
} from "phantasma-sdk-ts";

Initialize Deployer Keys

In the following examples, we will use the deployer’s PhantasmaKeys keypair and its Bytes32 public key.

Build NFT ROM

NftRomBuilder helps construct and serialize the NFT ROM.

Set NFT Minting Fees

MintNftFeeOptions is used to specify the fees for NFT minting. You can call the constructor without arguments to use default values.

Build and Sign the Transaction

MintNonFungibleTxHelper simplifies the process of building and signing the NFT minting transaction.

Broadcast the Transaction

Broadcast the transaction to the network.

Parse the Result

After the transaction is mined and its result becomes available, parse it to obtain the new Carbon NFT address. This address can later be used for infusion.

The method MintNonFungibleTxHelper.parseResult() returns an array of minted NFT addresses - in this case, it will contain a single element.

Last updated