2

When pda is created there is a bump associated with it. should that bump be stored in that pda itself or we can store it to some other pda also. which one is preferred, need those pda to sign some transaction.

3 Answers 3

2

In Anchor, you can setup your account to have bump = acc_var_name.bump to save the bump as part of the PDA.

For example:

#[derive(Accounts)]
pub struct PdaAccounts<'info> {
    #[account(mut)]
    pub counter: Account<'info, CounterData>,
    // only 1600 if using the bump that is saved in the counter_checked account
    #[account(
        seeds = [b"counter"],
        bump = counter_checked.bump
    )]
    pub counter_checked: Account<'info, CounterData>,
}

In the above struct, we have the counter_checked account saving the bump by using bump = counter_checked.bump. This will save CU on pda lookup.

0

i think the easiest way is to store it within the pda itself so you dont have to do external calls/reference other accounts in your code

0

Usually, when initializing a PDA, it's advisable to store the bump within the PDA itself. However, there are instances where bumps can be saved in a different PDA.

For example, consider a config PDA Acc. While you save the PDA within the configuration PDA itself, you may also:

a) Save bumps for unchecked accounts, typically for signing purposes.

b) Save bumps for system accounts.

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.