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.
Thaw re-enables token operations on a previously frozen account. Only the mint's freeze authority can thaw accounts.
Before we can freeze or thaw any token account, 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(),
},
),
)?;