Anchor
SPL Token with Anchor

SPL Token with Anchor

Mint To Instruction

Creates new tokens and deposits them into a specified account. Only the mint authority can perform this operation.

Before we can mint any token, we'll need to already have:

  • Initialized a Mint account which we hold the mintAuthority
  • Initialized a Token account or Associated Token account where we're going to mint tokens to

The amount of tokens we mint are "normalized" for decimals. This means that if we want to mint 1 token that has 6 decimals, we'll need to actually put 1_000_000 as amount

This is how the CPI to the mint_to() instruction looks like:

mint_to(
    CpiContext::new(
        ctx.accounts.token_program.to_account_info(),
        MintTo {
            mint: ctx.accounts.mint_account.to_account_info(),
            to: ctx.accounts.to_token_account.to_account_info(),
            authority: ctx.accounts.authority.to_account_info(),
        },
    ),
    &1_000_000,
)?;
Contents
View Source
Blueshift © 2025Commit: dd6c76d