1

I try to create a program with Anchor/Rust to mint a cNFT as a part of a collection, I have this following error on the anchor build and don't understand why he can't access the collection_mint inside the struct.

#[derive(Accounts)]
pub struct InitNFT<'info> {
#[account(mut, signer)]
pub signer: Signer<'info>,

#[account(
    init_if_needed,
    seeds = [SEED.as_bytes()],
    bump,
    payer = signer,
    mint::decimals = 0,
    mint::authority = signer,
    mint::freeze_authority = signer
)]
pub collection_mint: Account<'info, Mint>,

/// CHECK: address
#[account(
    mut,
    address=MetadataMPL::find_pda(&collection_mint.key()).0
)]
pub metadata_account: AccountInfo<'info>,

/// CHECK: address
#[account(
    mut,
    // address=MasterEdition::find_pda(&collection_mint.key()).0
)]
pub master_edition_account: AccountInfo<'info>,

/// CHECK:
#[account(
    mut,
    seeds = [merkle_tree.key().as_ref()],
    bump,
    seeds::program = bubblegum_program.key()
)]
pub tree_authority: UncheckedAccount<'info>,

/// CHECK:
#[account(mut)]
pub merkle_tree: UncheckedAccount<'info>,

 .......
}

The errors:

error[E0425]: cannot find value `collection_mint` in this scope
--> programs/solana-c-nft/src/lib.rs:214:40
    |
214 |         address=MetadataMPL::find_pda(&collection_mint.key()).0
    |                                        ^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `collection_mint` in this scope
--> programs/solana-c-nft/src/lib.rs:221:42
    |
221 |         address=MasterEdition::find_pda(&collection_mint.key()).0
    |                                          ^^^^^^^^^^^^^^^ not found in this scope

And the Cargo.toml

[workspace]
members = [
    "programs/solana-c-nft",
    "libs/account-compression",
    "libs/bubblegum"
]
resolver = "2"

[profile.release]
overflow-checks = true
lto = "fat"
codegen-units = 1
[profile.release.build-override]
opt-level = 3
incremental = false
codegen-units = 1

[workspace.dependencies]
anchor-gen = { git = "https://github.com/ChewingGlass/anchor-gen.git" }
anchor-lang = "0.30.0"
solana-program = "1.18.11"

Thanks for your time :)

2 Answers 2

1

After some research on the Anchor discord server, I find this solution, it look like a problem with the 0.30.0 version, Try to add this line on your Anchor.toml:

[features]
resolution = false
seeds = false
skip-lint = false

Shout out to @acheron of the core team

1
  • This worked for me. What is the issue here?
    – hackerboy
    Commented Aug 4 at 18:16
0

If you are trying to mint a cNFT, It is worth noting that compressed Assets do not contain the Master Edition and Metadata accounts.

They only need two accounts the tree config and merkle tree accounts. More on those on this page -> https://developers.metaplex.com/bubblegum/create-trees

As to why Anchor cannot access the account I am unsure.

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.