Skip to main content
added 103 characters in body
Source Link
Jimii
  • 7.7k
  • 1
  • 8
  • 22

I have my accounts struct like this

#[derive(Accounts)]
#[instruction(force_seed: [u8; 32])]
pub struct Dummy<'info> {
    #[account(mut)]
    pub payer: Signer<'info>,

    /// CHECK:
    #[account(
        mut,
        seeds = [RANDOMNESS_ACCOUNT_SEED.as_ref(), &force_seed],
        bump,
        seeds::program = orao_solana_vrf::ID
    )]
    pub random: AccountInfo<'info>,

    pub system_program: Program<'info, System>,
}

I want to pas in the force_seed argumentsargument with another parameter likeargument, dummy. Dummy will not be used in the Accounts struct, butonly force_seed. The issue is that when I different addresses areinclude dummy, the generated for randomPDA address account here random changes.

 pub fn guess(ctx: Context<Dummy>, dummy: u8,  force_seed: [u8; 32]) -> Result<()> {

        Ok(())
    }

I have my accounts struct like this

#[derive(Accounts)]
#[instruction(force_seed: [u8; 32])]
pub struct Dummy<'info> {
    #[account(mut)]
    pub payer: Signer<'info>,

    /// CHECK:
    #[account(
        mut,
        seeds = [RANDOMNESS_ACCOUNT_SEED.as_ref(), &force_seed],
        bump,
        seeds::program = orao_solana_vrf::ID
    )]
    pub random: AccountInfo<'info>,

    pub system_program: Program<'info, System>,
}

I want to pas in the force_seed arguments with another parameter like dummy, but when I different addresses are generated for random

 pub fn guess(ctx: Context<Dummy>, dummy: u8,  force_seed: [u8; 32]) -> Result<()> {

        Ok(())
    }

I have my accounts struct like this

#[derive(Accounts)]
#[instruction(force_seed: [u8; 32])]
pub struct Dummy<'info> {
    #[account(mut)]
    pub payer: Signer<'info>,

    /// CHECK:
    #[account(
        mut,
        seeds = [RANDOMNESS_ACCOUNT_SEED.as_ref(), &force_seed],
        bump,
        seeds::program = orao_solana_vrf::ID
    )]
    pub random: AccountInfo<'info>,

    pub system_program: Program<'info, System>,
}

I want to pas in the force_seed argument with another argument, dummy. Dummy will not be used in the Accounts struct, only force_seed. The issue is that when I include dummy, the generated PDA address account here random changes.

 pub fn guess(ctx: Context<Dummy>, dummy: u8,  force_seed: [u8; 32]) -> Result<()> {

        Ok(())
    }
Source Link
Jimii
  • 7.7k
  • 1
  • 8
  • 22

passing anchor `#[instruction]` argument with another argument results in different address generated

I have my accounts struct like this

#[derive(Accounts)]
#[instruction(force_seed: [u8; 32])]
pub struct Dummy<'info> {
    #[account(mut)]
    pub payer: Signer<'info>,

    /// CHECK:
    #[account(
        mut,
        seeds = [RANDOMNESS_ACCOUNT_SEED.as_ref(), &force_seed],
        bump,
        seeds::program = orao_solana_vrf::ID
    )]
    pub random: AccountInfo<'info>,

    pub system_program: Program<'info, System>,
}

I want to pas in the force_seed arguments with another parameter like dummy, but when I different addresses are generated for random

 pub fn guess(ctx: Context<Dummy>, dummy: u8,  force_seed: [u8; 32]) -> Result<()> {

        Ok(())
    }