토큰 민트 생성

민트 계정이란

민트 계정은 솔라나에서 토큰을 정의하고 고유하게 식별하며, 해당 민트의 모든 토큰 계정에 적용되는 공유 상태를 저장합니다.

Token Program은 Mint 계정 타입을 다음과 같이 정의합니다:

Mint Account Type
/// Mint data.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Mint {
/// Optional authority used to mint new tokens. The mint authority may only
/// be provided during mint creation. If no mint authority is present
/// then the mint has a fixed supply and no further tokens may be
/// minted.
pub mint_authority: COption<Pubkey>,
/// Total supply of tokens.
pub supply: u64,
/// Number of base 10 digits to the right of the decimal place.
pub decimals: u8,
/// Is `true` if this structure has been initialized
pub is_initialized: bool,
/// Optional authority to freeze token accounts.
pub freeze_authority: COption<Pubkey>,
}

모든 토큰은 하나의 mint account를 가지며, 민트 주소는 지갑, 애플리케이션 및 탐색기 전반에 걸쳐 토큰의 고유 식별자입니다.

예를 들어, USD Coin(USDC)은 민트 주소가 EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v입니다. 이 민트 주소는 솔라나 생태계 전체에서 USDC를 고유하게 식별합니다. 이 민트는 Solana Explorer에서 확인할 수 있습니다.

민트 계정 생성 방법

민트를 생성하려면 두 가지 명령어가 필요합니다:

  1. System Program의 CreateAccount 명령어는 새로운 rent-exempt 계정을 생성하고 Token Program을 새 계정의 프로그램 소유자로 할당합니다.
  2. Token Program의 InitializeMint 또는 InitializeMint2 명령어는 새 계정을 민트로 초기화합니다.

CreateAccount 명령어와 민트 초기화 명령어를 동일한 트랜잭션에 포함시키세요.

민트 초기화 중에 Token Program은 mint account가 아직 초기화되지 않았고 rent-exempt인지 확인합니다. 그런 다음 Token Program은 민트 권한, 동결 권한, 소수점 자릿수 및 is_initialized 플래그를 mint account 데이터에 기록합니다.

소스 참조

항목설명Token ProgramToken Extensions Program
Mint모든 mint account에 저장되는 기본 민트 상태입니다.SourceSource
InitializeMint계정 목록에 rent sysvar 계정을 필요로 하는 민트 초기화 명령어입니다.SourceSource
InitializeMint2계정 목록에 rent sysvar 계정을 필요로 하지 않는 민트 초기화 명령어입니다.SourceSource
_process_initialize_mint민트 초기화를 위한 공유 프로세서 로직입니다.SourceSource
process_initialize_mint*rsInitializeMint*를 위한 공개 핸들러입니다.SourceSource
process_initialize_mint2*rsInitializeMint2*를 위한 공개 핸들러입니다.SourceSource

Typescript

아래의 Kit 예제는 @solana/kit를 사용하는 권장 접근 방식을 보여줍니다. 참고용으로 @solana/web3.js를 사용하는 레거시 예제도 포함되어 있습니다.

Kit

import { generateKeyPairSigner } from "@solana/kit";
import { createLocalClient } from "@solana/kit-client-rpc";
import { tokenProgram } from "@solana-program/token";
const client = await createLocalClient().use(tokenProgram());
const mint = await generateKeyPairSigner();
const result = await client.token.instructions
.createMint({
newMint: mint, // New mint account to create.
decimals: 9, // Decimals to define on the mint account.
mintAuthority: client.payer.address, // Authority allowed to mint new tokens.
freezeAuthority: client.payer.address // Authority allowed to freeze token accounts.
})
.sendTransaction();
const mintAccount = await client.token.accounts.mint.fetch(mint.address);
console.log("Mint Address:", mint.address);
console.log("Mint Account:", mintAccount.data);
console.log("\nTransaction Signature:", result.context.signature);
Console
Click to execute the code.

Web3.js

import { Connection, Keypair, LAMPORTS_PER_SOL } from "@solana/web3.js";
import { createMint, getMint, TOKEN_PROGRAM_ID } from "@solana/spl-token";
const mintPubkey = await createMint(
connection,
feePayer,
feePayer.publicKey, // Authority allowed to mint new tokens.
feePayer.publicKey, // Authority allowed to freeze token accounts.
9, // Decimals to define on the mint account.
Keypair.generate(), // New mint account to create.
{
commitment: "confirmed"
},
TOKEN_PROGRAM_ID
);
const mintAccount = await getMint(
connection,
mintPubkey,
"confirmed",
TOKEN_PROGRAM_ID
);
console.log("Mint Address:", mintPubkey.toBase58());
console.log("Mint Account:", mintAccount);
Console
Click to execute the code.

Rust

Rust
use anyhow::Result;
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_commitment_config::CommitmentConfig;
use solana_sdk::{
program_pack::Pack,
signature::{Keypair, Signer},
transaction::Transaction,
};
use solana_system_interface::instruction::create_account;
use spl_token_interface::{id as token_program_id, instruction::initialize_mint, state::Mint};
#[tokio::main]
async fn main() -> Result<()> {
let client = RpcClient::new_with_commitment(
String::from("http://localhost:8899"),
CommitmentConfig::confirmed(),
);
let latest_blockhash = client.get_latest_blockhash().await?;
let transaction = Transaction::new_signed_with_payer(
&[
create_account(
&fee_payer.pubkey(), // Account funding account creation.
&mint.pubkey(), // New mint account to create.
mint_rent, // Lamports funding the new account rent.
Mint::LEN as u64, // Account size in bytes.
&token_program_id(), // Program that owns the new account.
),
initialize_mint(
&token_program_id(),
&mint.pubkey(), // Mint account to initialize.
&fee_payer.pubkey(), // Authority allowed to mint new tokens.
Some(&fee_payer.pubkey()), // Authority allowed to freeze token accounts.
9, // Decimals to define on the mint account.
)?,
],
Some(&fee_payer.pubkey()),
&[&fee_payer, &mint],
latest_blockhash,
);
let transaction_signature = client.send_and_confirm_transaction(&transaction).await?;
let mint_account = client.get_account(&mint.pubkey()).await?;
let mint_data = Mint::unpack(&mint_account.data)?;
println!("Mint Address: {}", mint.pubkey());
println!("Mint Account: {:#?}", mint_data);
println!("\nTransaction Signature: {}", transaction_signature);
Ok(())
}
Console
Click to execute the code.

Python

Python
#!/usr/bin/env python3
import asyncio
import json
from solana.rpc.async_api import AsyncClient
from solders.keypair import Keypair
from solders.message import Message
from solders.system_program import create_account, CreateAccountParams
from solders.transaction import Transaction
from spl.token.async_client import AsyncToken
from spl.token.instructions import initialize_mint, InitializeMintParams
from spl.token.constants import MINT_LEN, TOKEN_PROGRAM_ID
DECIMALS = 9
async def main():
rpc = AsyncClient("http://localhost:8899")
async with rpc:
create_mint_instructions = [
create_account(
CreateAccountParams(
from_pubkey=fee_payer.pubkey(), # Account funding account creation.
to_pubkey=mint.pubkey(), # New mint account to create.
lamports=mint_rent, # Lamports funding the new account rent.
space=MINT_LEN, # Account size in bytes.
owner=TOKEN_PROGRAM_ID, # Program that owns the new account.
)
),
initialize_mint(
InitializeMintParams(
program_id=TOKEN_PROGRAM_ID, # Token program to invoke.
mint=mint.pubkey(), # Mint account to initialize.
decimals=DECIMALS, # Decimals to define on the mint account.
mint_authority=fee_payer.pubkey(), # Authority allowed to mint new tokens.
freeze_authority=fee_payer.pubkey(), # Authority allowed to freeze token accounts.
)
),
]
latest_blockhash = await rpc.get_latest_blockhash()
transaction = Transaction(
[fee_payer, mint],
Message(create_mint_instructions, fee_payer.pubkey()),
latest_blockhash.value.blockhash,
)
result = await rpc.send_transaction(transaction)
token = AsyncToken(rpc, mint.pubkey(), TOKEN_PROGRAM_ID, fee_payer)
mint_info = await token.get_mint_info()
mint_account = {
"mint_authority": None if mint_info.mint_authority is None else str(mint_info.mint_authority),
"supply": mint_info.supply,
"decimals": mint_info.decimals,
"is_initialized": mint_info.is_initialized,
"freeze_authority": None if mint_info.freeze_authority is None else str(mint_info.freeze_authority),
}
print("Mint Address:", mint.pubkey())
print("Mint Account:")
print(json.dumps(mint_account, indent=2))
print("\nTransaction Signature:", result.value)
if __name__ == "__main__":
asyncio.run(main())
Console
Click to execute the code.

메타데이터 추가 방법

mint account는 기본 토큰 정보(공급량, 소수점 자릿수, 권한)만 저장합니다. 토큰에 이름, 심볼, 이미지와 같은 사람이 읽을 수 있는 메타데이터를 추가하려면 두 가지 옵션이 있습니다:

Is this page helpful?

목차

페이지 편집

관리자

© 2026 솔라나 재단.
모든 권리 보유.
연결하기