Post
Share your knowledge.
How to ensure secure module object access and mutation?
I developed a module with a DonutShop
containing a Balance
. I want to share this module without risking unauthorized manipulation of Balance
. Can other modules directly alter the Balance
if I only use getters/setters within the module?
- Move CLI
Answers
1Correct. An object can be mutated only by a function existing in the same module where the object was created. However, simply having getters and setters within the same module is not enough to fully protect the object's state. You must also implement mechanisms to restrict access to these functions. One common approach is using an AdminCap pattern, which involves creating a capability-based access control system. This ensures that only authorized entities can invoke certain functions, thereby preventing unauthorized manipulation of the object's state. Check out the AdminCap pattern for more information.
Do you know the answer?
Please log in and share it.
Move is an executable bytecode language used to implement custom transactions and smart contracts.

- MiniBob... SUI+31
1
- 0xduckmove... SUI+27
2
- HaGiang... SUI+26
3
- ... SUIharry phan+21
- ... SUIMarlKey+20
- ... SUI
- ... SUIVens.sui+15
- ... SUICarlkawIy+12
- ... SUI
- ... SUIkryptoschain+10