Is it possible to share the authority to freeze a token account with another wallet other than the token account owner? eg. A is the owner of token account and B is another wallet. I want to do so A gives access to freeze the token account to B and from then onwards B will be able to freeze/unfreeze the token account without the need for A until revoked permission again.
2 Answers
The Metaplex Metadata program has the FreezeDelegatedAccount
and ThawDelegatedAccount
instructions that can be used to delegate the freeze authority of a token account.
https://docs.metaplex.com/programs/token-metadata/instructions#thaw-the-token-account-as-a-delegate
If the token account is frozen by the delegate, the original owner cannot freely unfreeze(thaw) the account. It seems these instructions would only work for NFTs created using the Metaplex standard since they depend on using the NFT's Master Edition Account.
https://github.com/metaplex-foundation/metaplex-program-library/issues/470#issuecomment-1132700105
The important thing to notice is when creating the Master Edition Account, both the "Mint Authority" and the "Freeze Authority" are transferred to the Master Edition PDA!
That means, no one can mint tokens or freeze accounts without going through the Token Metadata program.
The Token Metadata program has no instruction that allows you to mint tokens so no one can ever mint additional tokens (which ensures the non-fungibility of the token).
However, the Token Metadata program has one instruction that allows you to freeze the Token Account of the NFT. This is the FreezeDelegatedAccount instruction you are using.
The requirements of that FreezeDelegatedAccount instruction are a bit unique. It requires you to be the Delegated Account of the Token Account to freeze.
In order to be the Delegated Account of a Token Account, the owner of that Token Account must first use the Approve instruction from the SPL Token program. I am not 100% if it is possible for the Delegated address to be the same as the Owner's address but if not you could simply use another keypair you own.
...
Now that you have a Delegated account on that Token Account, you can use the FreezeDelegatedAccount instruction of the Token Metadata program to freeze that Token Account.
...
Note that you can also unfreeze it later using that same Delegated Account via the ThawDelegatedAccount instruction of the Token Metadata program.
Freeze Authority
Controlling the Freeze Authority allows someone to freeze a Token account, making that account immutable until it is thawed.
One reason this authority is transferred to the Edition PDA of the Token Metadata program is, similarly to the Mint Authority, it increases the scope of potential new features and upgrades.
However, contrary to the Mint Authority, we actually make use of that authority in the program.
The FreezeDelegatedAccount and ThawDelegatedAccount instructions are the only instructions that make use of the Freeze Authority. They allow the Delegate of a Token account to freeze (and thaw) that Token account to make them what we call "Non-Transferable NFTs". This enables a variety of use-cases such as preventing someone from selling an NFT while it is listed in an escrowless marketplace.
Through the spl-token program, there's only one freeze authority that can be specified, and it's applicable to all tokens of the same mint. The freeze authority can then transfer their freeze authority to someone else. So in the situation you described:
A gives access to freeze the token account to B and from then onwards B will be able to freeze/unfreeze token account without the need of A until revoked permission again
You can create the token with a freeze authority:
$ spl-token create-token --enable-freeze
You can give the freeze authority to wallet B:
$ spl-token authorize <MINT_ADDRESS> freeze <NEW_FREEZE_AUTHORITY>
Updating <MINT_ADDRESS>
Current freeze authority: <WALLET_A>
New freeze authority: <WALLET_B>
Once wallet B has freeze authority, wallet A cannot revoke the authority. Wallet B must give the freeze authority back to A.