Skip to content

Is it possible to create dynamic resources on Aptos? #47

Discussion options

You must be logged in to vote

Yes, you can do this with objects on Aptos. Structs must be fixed, but you can have variable resources attached to the struct.

Resource groups allow it to be in a single storage slot, and you can add or remove resources to the objects. Then just check if the resource is there and handle behavior appropriately. The other option is to, use the 0x1::option::Option struct, which lets you have an optional field.

Here's an example where a collection object for an NFT is extended with a CollectionPoints struct from Daily Move:

https://github.com/aptos-labs/daily-move/blob/main/snippets/modifying-nfts/sources/modify_nfts.move#L33-L44

https://github.com/aptos-labs/daily-move/blob/main/snippets/mod…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gregnazario
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
1 participant