帖子
分享您的知识。
Dominikus 168
Mar 15, 2025
专家问答
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
分享
评论
答案
1Bolke 88
Mar 16 2025, 01:49正确. 一个对象只能由存在于创建该对象的同一模块中的函数进行突变. 但是,仅将 getter 和 setter 放在同一个模块中不足以完全保护对象的状态. 您还必须实现限制对这些功能的访问的机制. 一种常见的方法是使用 AdminCap 模式,这涉及创建基于能力的访问控制系统. 这样可以确保只有授权实体才能调用某些函数,从而防止未经授权地操纵对象的状态. 查看 AdminCap 模式 了解更多信息.
1
评论
你知道答案吗?
请登录并分享。
Move is an executable bytecode language used to implement custom transactions and smart contracts.
148帖子231答案

奖励活动五月
- 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