1

So I'm designing a dapp that'll utilize a single account that I want to serve as a pot that all players can deposit SOL into and the winner can claim the entire pot. However, I know there will be bottleneck issues when more than a few people try to write to that account at once which would be a problem during heavy traffic. What is the best way to handle this? I was thinking about creating a simple Queue system on the client-side that doesn't run the sendAndConfirm transaction until it's next in line.

I was wondering if anyone has come across this issue before? I imagine someone has, but I don't know if there's any open source code to use as inspiration before attempting to implement my own thing.

1 Answer 1

1

Solana can handle the traffic, and you can design your app in a way that is ambivalent about traffic (within certain size constraints).

For example, you could have a function that players can call in your program (on chain) that deposits the Sol of anyone that calls it into a PDA. The amount can be fixed, or set as a parameter or whatever. The player's wallet will prompt them to manually confirm the transaction.

You won't have collisions unless your program logic causes one. In the case of a basic Sol transfer, you will never have a collision. The worst that happens even when there is a collision (usually a seed collision) is that a transaction will fail, and you can pick that up with an error handler.

You can make a single PDA or use multiple PDAS to record whatever information you want about the transaction. The only major constraint you may end up dealing with are the size limitations of the Solana PDA.

AFAIK, if two transactions arrived at the exact same time, Solana VM would see that they modified the same accounts and run them sequentially.

1
  • Good to know. The only thing the instruction does is invokes the lamport transfer itself and updates the state of a few of the accounts initialized in the instruction. It's pretty straightfoward. I may still throw together a simple Queue system, nothing complex, just to be on the safe side
    – Brian M.
    Commented Dec 22, 2023 at 23:33

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.