1

I'm now developing NFT backed loan site. Before, I've sent NFT to escrow account but now I need to lock NFT in user's wallet. Anyone know about locking nft in user's wallet, please help me.

1 Answer 1

2

For NFTs, you can use look into using the FreezeDelegatedAccount and ThawDelegatedAccount instructions from the Metaplex Token Metadata program.

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.

3
  • Thank you for your posting answer.
    – Fable Frog
    Commented May 30, 2023 at 10:21
  • As you know there might be many NFTs in user's wallet. And their freeze authority is not mine. then how can I get freeze authority? or how can I transfer freeze authority of NFT to me?
    – Fable Frog
    Commented May 30, 2023 at 10:22
  • It doesn't work for pNFTs. Do you have an idea for pNFT how to implement staking? I think it can be implemented with lock and unlock of metaplex token metadata. But I can't figure out how it work with onchain program. github.com/metaplex-foundation/metaplex-program-library/blob/…
    – Julbh
    Commented Jun 16, 2023 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.