Skip to content

How to use nested map in Move #63

Answered by gregnazario
0xaptosj asked this question in Questions
Discussion options

You must be logged in to vote

There are three types of "Map-like" data structures in Aptos:

Table SmartTable and SimpleMap

There are tradeoffs for each on gas costs, and ease of use.

It depends on your use case.

I did a segment on this on twitter https://x.com/Greg_Nazario/status/1760809623194677725?s=20

But the tl;dr:

  1. SimpleMap is based in a vector, it doesn't scale > 10k, so if you want a large set you should stay away from it. Every lookup may iterate through the whole map.
  2. SimpleMap can't be nested.
  3. Table is useful, but it's not iterable. So, if you need to iterate over multiple values, and you don't know what they are ahead of time, I would not use it.
  4. SmartTable is iterable, and generally more efficient than Table

Replies: 2 comments 2 replies

Comment options

0xaptosj
Mar 13, 2024
Maintainer Author

You must be logged in to vote
1 reply
@gregnazario
Comment options

Answer selected by gregnazario
Comment options

You must be logged in to vote
1 reply
@0xaptosj
Comment options

0xaptosj Jan 17, 2025
Maintainer Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
move Questions related to the Move Language
3 participants