0

I want to create PDA with no data in it, only SOL balance is needed. Reading following questions (q1, q2) I found out that I need to create System Account PDA, but I am having trouble to implement this with anchor. Some small example how to create and use it would be appreciated.

There are some question that comes using System Account PDA:

  • In instruction context, System Account PDA should be specified as SystemAccount?
  • Would program be able to withdraw SOL from System Account PDA and ensure that the program is the only account that withdraw SOL?
  • When calling the transaction that withdraw SOL from System Account PDA, signers are not required since it's PDA and there is no private key?

1 Answer 1

2

You can create a PDA with an empty account struct. For example

pub struct Example<'info> {
    #[account(
        init,
        seeds = [..],
        bump,
        payer = ..,
        space = 8,
    )]
    empty_pda: Account<'info, Empty>  
}
#[account]
pub struct Empty {}
  1. No. An Account<'info> is what you should use.
  2. Yes a program will be able to withdraw sol from the PDA. By default, making the PDA a program account(as is done above) ensures that only the program can sign withdrawals from that PDA.
  3. Correct, signers are not required for a PDA in the client-side because PDAs have no private key and it's impossible for them to sign that way. Here's a link that shows how to withdraw sol from a PDA.
1
  • I was thinking of this solution, but I was confused and thought there may be a better solution.
    – Void
    Commented Aug 30, 2022 at 15:17

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.