Dynamic storage sizes in solana

Can solana accounts support vectors of an interderminate size? If so, where can we see a working implementation of this?

Hi @origami and welcome to the forum! :wave:

Solana accounts, as of right now, are not easily re-sizable, so storing a dynamic length data such as a vector in a single account doesn’t work very well.

What you can do instead, though, is create multiple accounts, instead of storing them in a vector.

For instance, you use the JSON RPC Api to get a list of accounts owned by a certain program, such as your Solana program.

You can also filter that list of accounts by matching only accounts that have a certain value at a certain byte offset in the account data.

I did this in my Solana demo program:

In my app, you need to be able to create an unlimited number of time slot reservations, associated to a specific user.

Instead of storing a vector of time slot reservations, I create a new Solana account for each reservation, and my app can filter out reservations for specific users by matching on the part of the reservation account that is associated to a specific users wallet address.


I’d be happy to explain more if you have more questions!