1

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

#[account(
    mut,
    seeds = [b"poll".as_ref(), poll_id.to_le_bytes().as_ref()],
    bump
)]
pub poll_account: Account<'info, PollAccount>,

#[account(
    init,
    payer = signer,
    space = 8 + CandidateAccount::INIT_SPACE,
    seeds = [poll_id.to_le_bytes().as_ref(), poll_account.poll_option_index.to_le_bytes().as_ref()],
    bump
)]
pub candidate_account: Account<'info, CandidateAccount>,

pub system_program: Program<'info, System>,

} Please help out with this

Full Code here👇 https://github.com/Josh0007-sunday/voteDao.git

1 Answer 1

1

Anchor expected all accounts to be initialized when executing an instruction.

I'm guessing that maybe poll_account isn't initialized and that's why you might be encountering an error with it's execution.

Perhaps initialize it with the init constraint or init_if_needed if you are unsure about its initialization

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.