Anchor
SPL Token di Anchor

SPL Token di Anchor

This content is being translated and will be available here when ready.

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:

rust
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,
)?;
Daftar Isi
Lihat Sumber
Blueshift © 2025Commit: 0ec4e4d