2

My code

use anchor_lang::prelude::*;
use anchor_lang::solana_program::pubkey;

declare_id!("8SQ7LtBoufLSXWbcHf7bXuEzFWksbLjE8T7jUi3Yxz1");

#[program]
pub mod cnft {

    use super::*;

    pub fn withdraw_cnft(ctx: Context<Withdraw>) -> Result<()> {

        let merkle_tree = pubkey!("EwxweDQtWzitdmJabX9irUXHbfjTBKujqWVaFtFGr3Gt");
        let lead_index : u32 = 1u32;

        msg!("Transfering CNFT {} from tree {}" , lead_index, merkle_tree);

        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize {}

error

 error[E0432]: unresolved import `crate`
 --> programs/cnft/src/lib.rs:6:1
  |
6 | #[program]
  | ^^^^^^^^^^ could not find `__client_accounts_withdraw` in the crate root
  |
  = note: this error originates in the attribute macro `program` (in Nightly builds, run with -Z macro-backtrace for more info)

and

error[E0412]: cannot find type `Withdraw` in this scope
  --> programs/cnft/src/lib.rs:11:39
   |
11 |     pub fn withdraw_cnft(ctx: Context<Withdraw>) -> Result<()> {
   |                                       ^^^^^^^^ not found in this scope

1 Answer 1

1

You'll need some the Withdraw type defined to be used as Context<Withdraw>, ie you can just add:

#[derive(Accounts)]
pub struct Withdraw {}

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.