Getting Started

Mint Fungible Tokens

Mint additional fungible tokens to increase the circulating supply of your token on Solana.

Mint Tokens

In the following section you can find a full code example and the parameters that you might have to change. This assumes you already have a fungible token created and want to mint more tokens.

1// To install all the required packages use the following command
2// npm install @metaplex-foundation/mpl-toolbox @metaplex-foundation/umi @metaplex-foundation/umi-bundle-defaults
3import {
4 createTokenIfMissing,
5 findAssociatedTokenPda,
6 mintTokensTo,
7} from '@metaplex-foundation/mpl-toolbox';
8import {
9 keypairIdentity,
10 publicKey,
11 transactionBuilder,
12} from '@metaplex-foundation/umi';
13import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
14import { readFileSync } from 'fs';
15
16// Initialize Umi with Devnet endpoint
17const umi = createUmi('https://api.devnet.solana.com')
18
19// Load your wallet/keypair
20const wallet = '<your wallet file path>'
21const secretKey = JSON.parse(readFileSync(wallet, 'utf-8'))
22const keypair = umi.eddsa.createKeypairFromSecretKey(new Uint8Array(secretKey))
23umi.use(keypairIdentity(keypair))
24
25// Your token mint address and destination wallet
26const mintAddress = publicKey('<your token mint address>')
27const destinationAddress = publicKey('<destination wallet address>')
28
29// Find the destination token account
30const destinationTokenAccount = findAssociatedTokenPda(umi, {
31 mint: mintAddress,
32 owner: destinationAddress,
33})
34
35// Create the destination token account if it doesn't exist and mint tokens
36await transactionBuilder()
37 .add(createTokenIfMissing(umi, {
38 mint: mintAddress,
39 owner: destinationAddress,
40 }))
41 // Mint 100 tokens to the destination
42 .add(
43 mintTokensTo(umi, {
44 mint: mintAddress,
45 token: destinationTokenAccount,
46 amount: 100,
47 }))
48 .sendAndConfirm(umi)
49
50console.log('Minted 100 tokens')
51console.log('Mint:', mintAddress)
52console.log('To:', destinationTokenAccount)

Parameters

Customize these parameters for your mint operation:

ParameterDescription
mintAddressThe token mint address
destinationAddressWallet address to receive the tokens
amountNumber of tokens to mint

How It Works

The minting process involves three steps, that you may or may not have to execute manually, depending on the tool you are using. The following steps are focusing on umi:

  1. Find destination token account - Locate the recipient's token account using findAssociatedTokenPda
  2. Create token account if needed - Use createTokenIfMissing to ensure the recipient has a token account
  3. Mint tokens - Execute the mint with mintTokensTo

Requirements

To mint additional tokens, you must be the mint authority - Only the wallet designated as the mint authority can mint new tokens

Important Notes

  • Depending on the tool you are using, you may or may not have to account for decimals. The amount should account for decimals (e.g., for 9 decimals, minting 1 token requires amount: 1_000_000_000)
  • You can mint to any wallet address—the token account will be created if it doesn't exist
  • Only the mint authority can mint new tokens