I was wondering if I want 2 accounts to deposit SOL to a PDA, would that imply to use a multisig or that can be done without multisig? Suppose 2 wallets have to deposit sol to that account, and based on an event, 1 gets the sol and the other loses it?
3 Answers
Both depositing accounts would have to sign. If you don't want to worry about setting up a multisig transaction you could break this up into multiple transactions (eg. first account deposits, second account deposits, payout).
It sounds like you are trying to create an atomic transaction where the winner and losers are determined within one transaction. If you are writing your own program, you can make both accounts signers and within your instruction do 2 CPI system program transfer calls from these 2 accounts to the PDA and reward the winner in the same instruction. In fact, to save compute budget, you might want to just calculate the winner then create one transfer call from the loser to the winner.
To complement @Albert Chen's answer, assuming you are not worried about atomicity and what you are unsure of is how to do the end transfer to the "winner":
- no multisig needed
- each depositor will separately sign for its own deposit to the PDA
- after the winner has been decided, the PDA can sign for the transfer from itself to the winner account
This escrow example might be interesting to check (specifically escrowed_maker_tokens
)