1

I need help with locking and unlocking SPL tokens. Does Solana or Metaplex provide any functionality for this, or do we need to work on a Rust program to achieve this?

2 Answers 2

2

Token 2022 has a couple extensions you might consider: https://spl.solana.com/token-2022/extensions

You could set a transfer fee of 100% which effectively locks the tokens.

You could set NonTransferable.

Or probably the best option is to add a Transfer Hook that checks with a very simple program to see if the token is locked or unlocked.

3
  • Thanks, but I need to lock and unlock specific amounts. For instance, if the total supply is 100 million, I want to lock 1 million initially, and after some time, lock an additional 1 million. Similarly, I want the ability to unlock different amount on different time.
    – Bobz
    Commented Feb 1 at 6:03
  • That kind of granularity is gonna require a program handling the transfers or a program you call with a transfer hook.
    – Whiteseal
    Commented Feb 1 at 18:55
  • Hi @ Whiteseal can we update the transfer fee?
    – Bobz
    Commented Mar 11 at 13:07
2

Yep. But it depends with what you want to achieve.

Here is a simple instruction to lock an NonFungible token using umi

import { lockV1 } from '@metaplex-foundation/mpl-token-metadata'

await lockV1(umi, {
  mint,
  authority,
  tokenStandard: TokenStandard.NonFungible,
}).sendAndConfirm(umi)

and unlock

import { unlockV1 } from '@metaplex-foundation/mpl-token-metadata'

await unlockV1(umi, {
  mint,
  authority,
  tokenStandard: TokenStandard.NonFungible,
}).sendAndConfirm(umi)

To note is that the number of accounts you interact with will change with different standard. For example, the pNFT standard introduces two a new way to lock asset with the Metadata delegate authority, where you transfer authority over the metadata account to a new authority.

Check out this section of the Metaplex docs https://developers.metaplex.com/token-metadata/delegates

1
  • basically, I need to lock fungible tokens. For example, if the total supply is 100 million, I want to initially lock 1 million. Later, I might lock an additional 1 million, and I also need the that to unlock different amounts at different times.
    – Bobz
    Commented Feb 1 at 6:07

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.