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 mint any token, we'll need to already have:
- Initialized a
Mint
account which we hold thefreezeAuthority
- Initialized a
Token
account orAssociated Token
account that we want to freeze or thaw
This is how the CPI to the freeze_account()
instruction looks like:
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:
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(),
},
),
)?;