Mint and Burn Assets

Minting and burning assets with Native Script and Plutus Script

Minting and burning assets is a common operation in blockchain applications. In the Cardano ecosystem, minting and burning are achieved through Native Scripts and Plutus Scripts.

The MeshTxBuilder is a powerful low-level APIs that allows you to build and sign transactions.

In this page, you will find the APIs to create transactions for minting and burning assets.

Minting with One Signature

In this section, we will see how to mint native assets with a MeshTxBuilder. For minting assets with smart contract, visit MeshTxBuilder - Smart Contract - Minting Assets with Smart Contract.

Firstly, we need to define the forgingScript with ForgeScript. We use the first wallet address as the "minting address" (you can use other addresses).

Then, we define the metadata.

Finally, we create a transaction and mint the asset with the lower level APIs.

Mint Asset

Mint an asset with a native script

Connect wallet to run this demo

No wallets installed

Minting Multiple Assets

Minting multiple assets with a single transaction is a common operation in blockchain applications. Like minting single assets, you can mint multiple assets by calling mint() and mintingScript multiple times.

You appending the metadata into one object and pass it to metadataValue() method.

Mint Multiple Assets

Mint multiple assets with a single transaction

Connect wallet to run this demo

No wallets installed

Burning assets

Like minting assets, we need to define the forgingScript with ForgeScript. We use the first wallet address as the "minting address". Note that, assets can only be burned by its minting address.

Then, we resolve the policy ID and hex of token name, setting set txBuilder.mint("-1", policyId, tokenNameHex)

Finally, we create a transaction and burn the asset with the lower level APIs.

Burn Native Assets

Burn native assets

Connect wallet to run this demo

No wallets installed

Minting Assets with Native Script

The above minting and burning one signature are indeed the mint and burn with native script examples. Here we would explain the logic you need to know for native script minting.

With MeshTxBuilder, you just need .mint() and provide script to mint or burn native script tokens:

On top on these 2 core logics, you can attach metadata if needed with .metadataValue(), and construct the transaction as needed.

Mint Assets with Native Script

Mint native assets with Native Script

Connect wallet to run this demo

No wallets installed

Minting Assets with Plutus Script

Minting Plutus tokens with MeshTxBuilder starts with anyone of the below script version indicators:

Followed by specifying the minting information:

Similar to unlocking assets, minting or burning Plutus tokens require providing redeemer and scripts. However, no datum information is needed in minting or burning.

Script of the token

The actual script can be either provided by transaction builder or referenced from an UTxO onchain.

  • (i) Reference script
  • (ii) Supplying script

Redeemer of the mint

Redeemer can be provided in different data types. If your MeshTxBuilder does not include an evaluator instance, you can also provide your budget for the unlock with this redeemer endpoint

Mint Assets with Plutus Script

Mint native assets with Plutus Script. For this example, the Plutus script expects a data field of 'mesh'.

Connect wallet to run this demo

No wallets installed

Minting Assets with CIP-68 Metadata standard

Minting CIP-68 tokens with MeshTxBuilder means 2 consecutive sets of minting APIs. The first is to mint the 100 token, and the second is the mint the 222 tokens:

A side note, Mesh also provides the utility function of CIP68_100(tokenNameHex: string) andCIP68_222(tokenNameHex: string) to help easily construct the token names as needed. So you dont have to memorize the prefix bytes to correctly mint the CIP68-compliant tokens.

Mint Assets with CIP68 metadata standard

Mint assets with CIP68 metadata standard where two assets are issued, one referencing the other user token.

Connect wallet to run this demo

No wallets installed

Minting Royalty Token

Royalty tokens is a special type of token that allows the creator to collect a royalty fee, this proposed standard will allow for uniform royalties' distributions across the secondary market space. Read CIP-27 for more information.

The implementation of royalty tokens is very simple, minting a token with 777 label, with "rate" and "addr" in the metadata.

Here is the example of the metadata:

Mint Native Assets

Mint native assets with ForgeScript

Connect wallet to run this demo

No wallets installed