Skip to main content

require_mint_authority

Function require_mint_authority 

Source
pub fn require_mint_authority(
    mint_account: &AccountView,
    expected_authority: &Address,
) -> ProgramResult
Expand description

Verify an SPL Mint account’s mint_authority COption field matches expected_authority.

SPL Mint layout (82 bytes total):

  • [0..4] COption tag for mint_authority (u32 LE; 0 = None, 1 = Some)
  • [4..36] mint_authority pubkey (only meaningful when tag == 1)
  • [36..44] supply (u64 LE)
  • [44] decimals
  • [45] is_initialized
  • [46..50] COption tag for freeze_authority
  • [50..82] freeze_authority pubkey

Behavior: if the tag says None, the check fails with InvalidAccountData (the caller asked for a specific authority but the mint has none). If the tag says Some and the stored pubkey does not match, the check fails with IncorrectAuthority. Separating the two error codes lets callers tell “no authority at all” apart from “wrong authority”.