Close one account and return lamports to multiple accounts

Hello. I have the following problem:

  • there is a user A (account) that can define a set of items to sell.
  • User A only receives all the money when all his items are sold.
  • any user B, C, ... (account) can buy an item that they want and that has not been sold to another user. For this, use a PDA so that the money goes to this account and in the end, it transfers everything to user A (smart contract).
    -There may be the case that user A cancels the sale, meaning that the objects that have been sold will be his property again, and the money of the users who have bought the objects must be returned.

I have the list of the users, which I store their Pubkey.

How can you close the account and transfer the money to the users who made the transfer?

This is a forum about the Rust program language. You'll have much better luck asking such a question on a Solana specific forum/chat/etc.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.