I've tried to follow and complete the following guide to create an NFT through Anchor, but after finishing writing the code following each step throroughly following error while compiling:
error[E0425]: cannot find value `mint` in this scope
--> programs/solana-try-nft/src/lib.rs:144:36
|
144 | address=find_metadata_account(&mint.key()).0,
| ^^^^ not found in this scope
|
help: consider importing this function
|
1 + use anchor_spl::token::accessor::mint;
|
error[E0425]: cannot find value `mint` in this scope
--> programs/solana-try-nft/src/lib.rs:150:42
|
150 | address=find_master_edition_account(&mint.key()).0,
| ^^^^ not found in this scope
|
help: consider importing this function
|
1 + use anchor_spl::token::accessor::mint;
|
For more information about this error, try `rustc --explain E0425`.
error: could not compile `solana-try-nft` (lib test) due to 2 previous errors
Error: Building IDL failed
This is the struct I am trying to create:
#[derive(Accounts)]
pub struct InitNFT<'info> {
/// CHECK: ok, we are passing this account ourselves
#[account(mut, signer)]
pub signer: AccountInfo<'info>,
#[account(
init,
payer = signer,
mint::decimals = 0,
mint::authority = signer.key(),
mint::freeze_authority = signer.key(),
)]
pub mint: Account<'info, Mint>,
#[account(
init_if_needed,
payer = signer,
associated_token::mint = mint,
associated_token::authority = signer,
)]
pub associated_token_account: Account<'info, TokenAccount>,
/// CHECK - address
#[account(
mut,
address=find_metadata_account(&mint.key()).0,
)]
pub metadata_account: AccountInfo<'info>,
/// CHECK: address
#[account(
mut,
address=find_master_edition_account(&mint.key()).0,
)]
pub master_edition_account: AccountInfo<'info>,
pub token_program: Program<'info, Token>,
pub associated_token_program: Program<'info, AssociatedToken>,
pub token_metadata_program: Program<'info, Metadata>,
pub system_program: Program<'info, System>,
pub rent: Sysvar<'info, Rent>
}
Both lines that refer to the address like address=find_master_edition_account(&mint.key()).0, and address=find_metadata_account(&mint.key()).0, where a reference to mint is used are being flagged as mint not known in the scope. Despite having imported the needed dependencies. How could I fix this?