2

When doing init with anchor, is the pda owned by the program that creates it or by the system program?

1 Answer 1

3

If you use the init constraint it will assign ownership to the program calling the function unless you ask it to assign a different owner using the owner constraint. e.g.

    #[account(
        init, payer = payer, space = 8 + 8,
        owner = other_program.key(),
        seeds = [b"other_seed"], bump
    )]
    pub pda_for_other_program: AccountInfo<'info>,

You don't need to init a PDA that you want to be owned by the system program because all accounts are owned by the system program by default.

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.