Skip to main content

Mint a Fungible Token

A fungible token is a native token minted with a quantity greater than one, where every unit is interchangeable. You define a minting policy, mint the supply, and the tokens then move through ordinary transactions. Pick your tool below.

What you'll build

  • A signature-based minting policy
  • A supply of one fungible token minted to your own address
  • (Optional) a burn transaction that destroys some of them

Prerequisites

  • Test ADA on Preview or Pre-Production (faucet)
  • A provider key (Blockfrost) for the SDK tabs, or a running node for cardano-cli
  • Min-ADA travels with tokens, keep a little ADA in the output (why)

Mint it

import { Assets, Data, preprod, Client } from "@evolution-sdk/evolution"

const client = Client.make(preprod)
.withBlockfrost({
baseUrl: "https://cardano-preprod.blockfrost.io/api/v0",
projectId: process.env.BLOCKFROST_API_KEY!
})
.withSeed({ mnemonic: process.env.WALLET_MNEMONIC!, accountIndex: 0 })

declare const mintingPolicy: any // native script or smart contract, see Minting policies

const policyId = "7edb7a2d9fbc4d2a68e4c9e9d3d7a5c8f2d1e9f8a7b6c5d4e3f2a1b0"
const assetName = "4d79546f6b656e" // "MyToken" in hex

let assets = Assets.fromLovelace(0n)
assets = Assets.addByHex(assets, policyId, assetName, 1000n) // quantity > 1

const tx = await client
.newTx()
.mintAssets({ assets, redeemer: Data.constr(0n, []), label: "mint-my-token" })
.attachScript({ script: mintingPolicy })
.build()

const signed = await tx.sign()
await signed.submit()

The builder tracks the policy, indexes redeemers, evaluates execution units, and calculates fees for you.

Burn tokens

Burning is minting with a negative quantity, authorized by the same policy.

let burn = Assets.fromLovelace(0n)
burn = Assets.addByHex(burn, policyId, assetName, -500n)

const tx = await client
.newTx()
.mintAssets({ assets: burn, redeemer: Data.constr(1n, []), label: "burn-tokens" })
.attachScript({ script: mintingPolicy })
.build()

await (await tx.sign()).submit()

Next steps