1

I am using PDA as a vault that represents reward of a bet. Player needs to transfer bet amount to Reward PDA by sending and signing the transaction. In the same time, same bet amount is withdrawn from House PDA which already created by same program as Reward PDA. So program is allowed to withdraw sol from House PDA because House PDA is owned by the program.

The problem that I am facing is that I want to replace House PDA with my personal wallet and to allow program to withdraw funds from my wallet automatically every time player runs the game. How can I achieve that?

2
  • If you do it this way you'd have to be available to sign and approve any withdrawal transaction? Is there a good reason why you want it to be from your personal wallet instead? The more intuitive approach is to leave it as is, just have an account hold funds for users to withdraw from, you can top it up from your personal wallet to prevent funds from running out
    – Ademola
    Commented Aug 26, 2022 at 20:00
  • Firstly how can you tell which account is a pda and which isn't? Make sure you're not moving along on assumptions that are incorrect. Next it's definitely possible to transfer sol from you wallet to another account but no that can't be done automatically as you would have to sign your approval for the transaction each time
    – Ademola
    Commented Aug 26, 2022 at 20:42

1 Answer 1

1

you will have to create a System Account PDA for that program which then you can deposit SOL into that account and make the program use the SOL in that PDA since it has the authorization to do it.

Read here about PDAs

1
  • if it's a pda then the program can Withdraw or Modify the account since he has control over that account. Pdas don't have a private key since they are off curve but programs can generate a valid transaction modifying that PDA.
    – vicyyn
    Commented Aug 26, 2022 at 18:11

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.