Anchor
SPL Token di Anchor

SPL Token di Anchor

This content is being translated and will be available here when ready.

Freeze and Thaw Instructions

Freeze prevents all token operations on an account until it's thawed. Only the mint's freeze authority can perform this operation.

Completely disables transfers, approvals, and burns and it only affects the specific frozen account

Thaw re-enables token operations on a previously frozen account. Only the mint's freeze authority can thaw accounts.

Restores full functionality to a frozen account and can only be performed by the mint's freeze authority

Before we can freeze or thaw any token account, we'll need to already have:

  • Initialized a Mint account which we hold the freezeAuthority
  • Initialized a Token account or Associated Token account that we want to freeze or thaw

This is how the CPI to the freeze_account() instruction looks like:

rust
freeze_account(
    CpiContext::new(
        ctx.accounts.token_program.to_account_info(),
        FreezeAccount {
            account: ctx.accounts.token_account.to_account_info(),
            mint: ctx.accounts.mint.to_account_info(),
            authority: ctx.accounts.authority.to_account_info(),
        },
    ),
)?;

And this is how the CPI to the thaw_account() instruction looks like:

rust
thaw_account(
    CpiContext::new(
        ctx.accounts.token_program.to_account_info(),
        ThawAccount {
            account: ctx.accounts.token_account.to_account_info(),
            mint: ctx.accounts.mint.to_account_info(),
            authority: ctx.accounts.authority.to_account_info(),
        },
    ),
)?;
Daftar Isi
Lihat Sumber
Blueshift © 2025Commit: 0ec4e4d