Skip to main content

  1. Mint To creates new tokens of a mint and deposits them to a specified token account.
  2. Before we can mint any tokens, we need an initialized mint account (SPL, Token-2022 or Light) for which we hold the mint authority.

Get Started

mintToInterface mints tokens to token accounts in a single call.The function auto-detects the token program (SPL, Token-2022, or Light) from the mint address.Compare to SPL:
Find the source code here.
1

Mint Tokens to Light-Token Account

import { Keypair } from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import {
  createMintInterface,
  createAtaInterface,
  mintToInterface,
  getAssociatedTokenAddressInterface,
} from "@lightprotocol/compressed-token";

async function main() {
  const rpc = createRpc();
  const payer = Keypair.generate();
  await rpc.requestAirdrop(payer.publicKey, 10e9);

  const mintSigner = Keypair.generate();
  const { mint } = await createMintInterface(
    rpc,
    payer,
    payer,
    null,
    9,
    mintSigner,
  );

  const recipient = Keypair.generate();
  await createAtaInterface(rpc, payer, mint, recipient.publicKey);

  const destination = getAssociatedTokenAddressInterface(mint, recipient.publicKey);
  const amount = 1_000_000_000;

  const txSignature = await mintToInterface(
    rpc,
    payer,
    mint,
    destination,
    payer,
    amount,
  );

  console.log("Minted tokens:", amount);
  console.log("Transaction:", txSignature);
}

main().catch(console.error);

Next Steps

Learn to use the transfer interface for light-token <> SPL token transfers