Permanent data in a stable memory, not really permanent

There are plenty of stable data structure collections that have been developed by the community.

Here’s a few that I’d recommend, all that use MOPS - on-chain package manager for Motoko! for easy 3rd-party Motoko library integration.

In general, I’d recommend heap-based stable collections over ones that directly manipulate stable memory since the Motoko team is currently working on improvements to the language and compiler that will provide a “stable heap” on top of the DFINITY foundation’s current work to bring wasm64 to canisters.

Here are a few data structures you might use often/find helpful:

You can find tons of Motoko packages at https://mops.one/

Btw, a few years ago, I had a similar question to you and asked it here → Clarification on Stable Types with Examples. That thread has some information on how you can write your own stable collection if you’re at all interested.

1 Like