0

I have been working with pNFT lock function but I can't figure out how to invoke the mpl-token-metadta function. Anyone has an experience with lock function?

Here is references.

https://github.com/metaplex-foundation/metaplex-program-library/blob/master/token-metadata/program/ProgrammableNFTGuide.md

https://docs.rs/mpl-token-metadata/1.12.0/mpl_token_metadata/processor/fn.lock.html

1 Answer 1

0

mpl-token-metadata is not actually a function, it's an on-chain program with multiple entrypoints.

One of those entrypoints allows you to lock a pNFT. The example you've posted is from version 1.1.2 documentation. However, you really should be using the latest mpl-token-metadata (3.1.0). Version 3 has a really convenient set of instruction builders that save you a lot of pain and headache.

The builder you should be using is LockV1Builder.

All builders (including LockV1Builder which you would be using) are used in the same way, i.e:

  1. create instruction using a builder (CreateV1Builder, LockBuilder, UnlockV1Builder etc)
  2. figure out the account infos that are needed for the call. If in doubt, each builder has a Accounts struct specified in the code - usually the same source file as the builder itself.
  3. invoke the instruction with the appropriate signers and account infos

The following is an example from CreateV1Builder (this is used for creating metadata) - however as mentioned above, LockV1Builder works exactly the same way.

let create_ix = CreateV1Builder::new()
        .metadata(accounts.nft_metadata.key())
        .mint(accounts.nft_mint.key(), accounts.nft_mint.is_signer)
        .authority(accounts.nft_mint_authority.key())
        .payer(accounts.payer.key())
        .update_authority(accounts.authority_pda.key(), true)
        .master_edition(Some(accounts.nft_master_edition.key()))
        .creators(creators)
        .seller_fee_basis_points(seller_fee_basis_points)
        .is_mutable(true)
        .name(name)
        .symbol(symbol)
        .uri(uri)
        .collection(Collection {
            verified: false,
            key: collection_mint,
        })
        .decimals(0)
        .print_supply(if max_supply == 0 {
            PrintSupply::Zero
        } else {
            PrintSupply::Limited(max_supply)
        })
        .instruction();

    let create_infos = vec![
        accounts.nft_metadata.to_account_info(),
        accounts.nft_mint.to_account_info(),
        accounts.nft_mint_authority.to_account_info(),
        accounts.payer.to_account_info(),
        accounts.authority_pda.to_account_info(),
        accounts.nft_master_edition.to_account_info(),
        accounts.system_program.to_account_info(),
        sysvar_instructions_info.to_account_info(),
        accounts.spl_token_program.to_account_info(),
    ];

    invoke_signed(&create_ix, &create_infos, &[&authority_seeds])?;
``

Your Answer

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

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