DeveloperBreeze

Token Minting Development Tutorials, Guides & Insights

Unlock 2+ expert-curated token minting tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your token minting skills on DeveloperBreeze.

Using Solana's Program Library: Building Applications with Pre-Built Functions

Tutorial August 27, 2024
rust

use anchor_lang::prelude::*;
use spl_token::instruction::mint_to;
use solana_program::program::invoke;

declare_id!("YourProgramID");

#[program]
pub mod solana_spl_tutorial {
    use super::*;

    pub fn mint_token(ctx: Context<MintToken>, amount: u64) -> Result<()> {
        let cpi_accounts = MintTo {
            mint: ctx.accounts.mint.to_account_info(),
            to: ctx.accounts.token_account.to_account_info(),
            authority: ctx.accounts.authority.to_account_info(),
        };
        let cpi_program = ctx.accounts.token_program.to_account_info();
        let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts);

        invoke(
            &mint_to(
                ctx.accounts.token_program.key,
                ctx.accounts.mint.key,
                ctx.accounts.token_account.key,
                ctx.accounts.authority.key,
                &[],
                amount,
            )?,
            &[
                ctx.accounts.mint.to_account_info(),
                ctx.accounts.token_account.to_account_info(),
                ctx.accounts.authority.to_account_info(),
            ],
        )?;

        Ok(())
    }
}

#[derive(Accounts)]
pub struct MintToken<'info> {
    #[account(mut)]
    pub mint: AccountInfo<'info>,
    #[account(mut)]
    pub token_account: AccountInfo<'info>,
    #[account(signer)]
    pub authority: AccountInfo<'info>,
    pub token_program: AccountInfo<'info>,
}

This simple program demonstrates how to use the SPL Token Program to mint new tokens.

Creating a Token on Solana

Tutorial August 09, 2024
bash rust

Note the token mint address returned by this command, as you'll need it for minting and transferring tokens.

Create a token account to hold your newly created tokens. This account is associated with your wallet: