Solana의 자산

토큰은 다양한 범주의 자산에 대한 소유권을 나타내는 디지털 자산입니다. 토큰화는 재산권의 디지털화를 가능하게 합니다. Solana의 토큰은 SPL(Solana Program Library) 토큰이라고 합니다.

The Token Program updates a mint and its token accounts while owners authorize balance changes

이 섹션에서는 Solana에서 토큰이 표현되는 방식에 대한 기본 개념을 다룹니다. 코드 예제는 SPL Token Basics 섹션을 참조하세요.

핵심 사항

  • Token Programs에는 네트워크에서 토큰(대체 가능 및 대체 불가능 모두)과 상호작용하기 위한 모든 명령어 로직이 포함되어 있습니다.

  • Mint Account는 특정 토큰을 나타내며 총 공급량 및 mint authority(토큰의 새로운 단위를 생성할 권한이 있는 주소)와 같은 토큰에 대한 전역 메타데이터를 저장합니다.

  • Token Account는 특정 소유자에 대한 특정 mint account의 토큰에 대한 개별 소유권을 추적합니다.

  • Associated Token Account는 소유자와 mint account 주소에서 파생된 주소로 생성된 token account입니다.

Token Programs

Solana 생태계에는 두 가지 주요 Token Programs가 있습니다. 아래는 두 프로그램의 소스 코드입니다.

Token Programs에는 네트워크에서 토큰(대체 가능 및 대체 불가능 모두)과 상호작용하기 위한 모든 명령어 로직이 포함되어 있습니다. Solana의 모든 토큰은 실질적으로 Token Program이 소유한 데이터 계정입니다.

Token ProgramToken Program

Mint Account

Solana의 토큰은 Token Program이 소유한 Mint Account의 주소로 고유하게 식별됩니다. 이 계정은 특정 토큰에 대한 전역 카운터 역할을 하며 다음과 같은 데이터를 저장합니다:

  • Supply: 토큰의 총 공급량
  • Decimals: 토큰의 소수점 정밀도
  • Mint authority: 토큰의 새로운 단위를 생성하여 공급량을 증가시킬 수 있는 권한이 있는 계정
  • Freeze authority: Token Account의 토큰을 동결하여 전송 또는 소각을 방지할 수 있는 권한이 있는 계정

발행 권한은 mint가 초기화될 때 설정됩니다. 이는 향후 발행을 승인하지만, mint account를 생성하거나 비용을 지불한 계정일 필요는 없습니다.

Mint AccountMint Account

각 mint account에 저장되는 전체 세부 정보는 다음과 같습니다:

Mint Account State
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>,
}

참고로, 다음은 USDC mint account에 대한 Solana Explorer 링크입니다.

토큰 계정

Token Program은 각 토큰 단위의 개별 소유권을 추적하기 위해 token account를 생성합니다. token account는 다음과 같은 데이터를 저장합니다:

  • Mint: token account가 보유하는 토큰의 단위
  • Owner: token account에서 토큰을 전송할 수 있는 권한이 있는 계정
  • Amount: token account가 현재 보유하고 있는 토큰의 수량

Token AccountToken Account

각 token account에 저장되는 전체 세부 정보는 다음과 같습니다:

Token Account State
pub struct Account {
/// The mint associated with this account
pub mint: Pubkey,
/// The owner of this account.
pub owner: Pubkey,
/// The amount of tokens this account holds.
pub amount: u64,
/// If `delegate` is `Some` then `delegated_amount` represents
/// the amount authorized by the delegate
pub delegate: COption<Pubkey>,
/// The account's state
pub state: AccountState,
/// If is_native.is_some, this is a native token, and the value logs the
/// rent-exempt reserve. An Account is required to be rent-exempt, so
/// the value is used by the Processor to ensure that wrapped SOL
/// accounts do not drop below this threshold.
pub is_native: COption<u64>,
/// The amount delegated
pub delegated_amount: u64,
/// Optional authority to close the account.
pub close_authority: COption<Pubkey>,
}

지갑이 보유하려는 각 토큰(mint)에 대해 token account가 필요하며, 지갑 주소가 token account 소유자로 설정됩니다. 각 지갑은 동일한 토큰(mint)에 대해 여러 token account를 소유할 수 있지만, token account는 한 명의 소유자만 가질 수 있고 하나의 토큰(mint)의 단위만 보유할 수 있습니다.

Account RelationshipAccount Relationship

각 Token Account의 데이터에는 해당 token account에 대한 권한을 가진 주체를 식별하는 owner 필드가 포함되어 있습니다. 이는 모든 Token Account에 대해 Token Program인 기본 Account 유형에 지정된 프로그램 소유자와는 다릅니다.

Associated token account

Associated Token Account는 특정 mint와 소유자에 대한 token account 주소를 찾는 과정을 단순화합니다. Associated Token Account를 특정 mint와 소유자에 대한 "기본" token account로 생각하면 됩니다.

Associated Token Account는 소유자의 주소와 mint account의 주소에서 파생된 주소로 생성됩니다. Associated Token Account는 특정 주소를 가진 token account일 뿐이라는 점을 이해하는 것이 중요합니다.

이는 Solana 개발의 핵심 개념인 Program Derived Address (PDA)를 소개합니다. PDA는 미리 정의된 입력을 사용하여 주소를 결정론적으로 파생하므로 계정의 주소를 쉽게 찾을 수 있습니다.

Associated Token AccountAssociated Token Account

각 지갑은 동일한 mint의 토큰을 보유하기 위해 자체 token account가 필요합니다.

확장된 계정 관계확장된 계정 관계

Is this page helpful?

목차

페이지 편집