6

I am using the following Anchor dependencies:

anchor-lang = "0.27.0"
anchor-spl = { version = "0.27.0", features = ["metadata"] }

But it breaks when compiling because seems like the create_metadata_accounts_v2 function doesn't exist anymore within the mpl_token_metadata library:

error[E0425]: cannot find function `create_metadata_accounts_v2` in module `mpl_token_metadata::instruction`
   --> src/metadata.rs:24:47
    |
24  |       let ix = mpl_token_metadata::instruction::create_metadata_accounts_v2(
    |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `create_metadata_accounts_v3`

I am just using it to obtain the token metadata:

use anchor_spl::metadata::MetadataAccount;

#[derive(Accounts)]
pub struct Allowed<'info> {
   #[account()]
   pub signer: Signer<'info>,
   ...
   ...
   #[account(
       seeds = [b"metadata", mpl_token_metadata::ID.as_ref(), metadata.mint.key().as_ref()],
       seeds::program = mpl_token_metadata::ID,
       constraint = metadata.mint == token.as_ref().unwrap().mint @ Unauthorized,
       bump,
   )]
   pub metadata: Option<Account<'info, MetadataAccount>>,
}

Does somebody know how to fix this issue?

2 Answers 2

6

Just add mpl-token-metadata using "=1.9.0" within your Cargo.toml dependencies, E.G:

[dependencies]
anchor-lang = "0.27.0"
anchor-spl = { version = "0.27.0", features = ["metadata"] }
mpl-token-metadata = { version = "=1.9.0", features = ["no-entrypoint"] }

1

You can just use create_metadata_accounts_v3 instead. https://github.com/coral-xyz/anchor/blob/master/spl/src/metadata.rs#L98

create_metadata_accounts_v2 will be removed in the next anchor release.

https://github.com/coral-xyz/anchor/blob/master/CHANGELOG.md#breaking

2
  • Well yeah, but how can I do that if that is actually part of anchor-spl v0.27.0 itself. I cannot get rid of that error unless I wait to Anchor 0.28.0? Commented May 16, 2023 at 23:04
  • I mean create_metadata_accounts_v3 already supported in anchor 0.27.0 Commented May 17, 2023 at 6: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.