I am following this tutorial to build a lottery on Solana, which works totally fine on Solana Playground / https://beta.solpg.io/, but once i move the code to Visual code i'm getting some errors. Please help!! Here is the error i'm getting:

Error[E0425]: cannot find value `master` in this scope
   --> programs/btc/src/lib.rs:192:45
192 |         seeds = [LOTTERY_SEED.as_bytes(), &(master.last_id + 1).to_le_bytes()],
    |                                             ^^^^^^ not found in this scope

Here is the code:

pub struct CreateLottery<'info> {
        payer = authority,
        space = (4 + 32 + 8 + 4 + 1 + 4 + 1) + 8,
        seeds = [LOTTERY_SEED.as_bytes(), &(master.last_id + 1).to_le_bytes()],
    pub lottery: Account<'info, Lottery>,

        seeds = [MASTER_SEED.as_bytes()],
    pub master: Account<'info, Master>,

    pub authority: Signer<'info>,
    pub system_program: Program<'info,System>,

pub struct Lottery {
        pub id: u32, // the id, 
        pub authority: Pubkey, // and who has auth over the lottery
        pub ticket_price: u64,
        pub last_ticket_id: u32,
        pub winner_id: Option<u32>, //(1+4) 
        pub claimed: bool,
New contributor
aDvo is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • I believe this should work. Isn't there some other omission in your code? Do you have the whole project published somewhere?
    – chalda
    Commented Jun 12 at 7:52
  • I don't have it published... but if u don't mind just popping this into anchor 0.30.0 it doesn't seem to work. This part seems to compile fine if using anchor 0.29.0 but i'm seeing some other errors there, so i'm not 100% sure i've solved the problem.
    – aDvo
    Commented Jun 12 at 17:11
  • I tried similar at 0.29.0 and it works (as you mentioned). I do not have direct experience with 0.30.0 but the changelog does not seem to be much helpful about it (github.com/coral-xyz/anchor/blob/master/CHANGELOG.md#breaking-1)
    – chalda
    Commented Jun 13 at 8:22


Your Answer

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

Browse other questions tagged or ask your own question.