Move.

Post

Share your knowledge.

Dominikus .
Mar 15, 2025
Expert Q&A

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
1
1
Share
Comments
.

Answers

1
Bolke .
Mar 16 2025, 01:49

Correct. 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.

1
Comments
.

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.

148Posts231Answers
Sui.X.Peera.

Earn Your Share of 1000 Sui

Gain Reputation Points & Get Rewards for Helping the Sui Community Grow.

Reward CampaignMay
We use cookies to ensure you get the best experience on our website.
More info