1

So im making a program that CPIs into marinade. In one of the instructions, they have a "transfer_sol_to" account requirement. I want the sol from that instruction to be transferred to a programs vault. I know if they simply mutated the value of the sol balance of the account this would be possible however looking at their code they use the system_instruction::transfer function to transfer to the "transfer_sol_to" account. So the question is, how do I make a system account that is owned by a PDA?

Anchor btw

2
  • What do you mean by a system account? Also(and do correct me on this), I assume that your actual aim here is to transfer sol to a PDA vault?
    – Ademola
    Commented Jul 29, 2022 at 19:00
  • yes i just want to transfer sol to a PDA vault. The marinade instruction im calling will use the system_instruction::transfer to transfer the sol to the account i pass in as transfer_sol_to Commented Jul 29, 2022 at 19:15

1 Answer 1

3

Before it's created, your PDA is a system program account. So instead of initing the PDA just send solana to it. And then sign using its seeds whenever you want to transfer sol out of it using the system program instructions.

So don't make a PDA that owns a system program account, just use a PDA that is a system program account.

3
  • Just make sure that the PDA account is always rent exempt (rent.minimum_balance(0)). If it ever goes below that value then the blockchain will deduct rent for each epoch.
    – nibbus
    Commented Jul 30, 2022 at 0:34
  • how do i make it rent exempt without initing? Commented Jul 30, 2022 at 7:34
  • Just put sol in it
    – Henry E
    Commented Jul 30, 2022 at 13:13

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.