0

When developing contract in solana, I had seen some example (include example in solana cook book - https://solanacookbook.com/gaming/store-sol-in-pda.html#tiny-adventure-anchor-program-part-two) had design there contract with 2 type PDA account: one for store business data, one use as a vault (store the token). Basically I had try another way the store all business data and token in just one PDA and can handle deposit, withdraw well, so the question that is split to 2 account above is the best practice or not, and why use that solution

1 Answer 1

1

There's no good or bad practice here, it all depends on your use case and how you want to structure it. Storing both in one PDA works too like you did since this is a simple example. But imagine if the chest had more details -- Perhaps a chest name, chest date, chest colours etc., in that case, it'd be better to seperate them out so that the vault PDA can not only store the tokens, but also hold other attributes about itself.

Generally speaking, each PDA account needs to be initialized with some rent amount, so if you can somehow lower the number of PDAs for your usecase, thats generally better. But of course, if your use case demands more, you can add more, hence there's no universal answer to what's good and what's bad here.

Not the answer you're looking for? Browse other questions tagged or ask your own question.