引言
经过之前的学习,我准备进行实战开发一个简单的dao项目demo,实现一个去中心化自治组织,用于管理共享资金、社区任务、提案和投票等功能,这篇文章分享了开发前期的系统设计。
功能描述
dao
token
关于dao
token
dao
使用了社区代币dao
来治理社区,并进行社区激励,社区成员需要使用dao
代币来发布提案,参与投票,从而参与社区治理,它的总供应在dao
被创立时已经被固定,初始状况下dao代币将会全部锁在金库中。
如何获取dao代币?
dao
组织会发布社区任务,设置一定的dao代币奖励,完成者可获得相应凭证,可以申请dao
代币。
社区成员发布的提案如果被接受,会根据提案的等级,分发一定的dao
代币奖励。
成员角色
社区中有三种成员角色:
1.InitCoreMember
dao
组织的初始核心成员
可以授权的角色:InitCoreMember,CoreMember。
2.CoreMember
dao
组织的核心成员:
可授权的角色: Member.
权利:
- 发布社区任务
- 分发任务奖励
- 授权普通社区成员
- 关闭提案
- 修改提案等级
3.Member
dao
组织的普通成员
权利:
- 发布提案
- 收获提案奖励
- 参与投票
如何运行
- DAO组织的初始成员发布社区任务
- 通过参与社区任务,持有dao代币,可以申请加入DAO组织
- 加入DAO组织后,可以发布社区提案,提案如果被接受,可以获取一定代币收益。可以参与提案投票。
obj设计
Dao
struct Dao<phantom T> has key{
id: UID,
total_members: u64, //Total Number of DAO Members
total_supply: Supply<T>, //Total Supply of DAO Tokens
}
dao组织的元数据,储存了dao组织的成员数量,和dao代币的总供应
Treasury
struct Treasury<phantom T> has key,store{
id:UID,
supply: Balance<T>, //Balance Stored in the Treasury
}
dao组织的金库,用于支付代币收益分配
初始核心成员权限凭证
struct InitCoreCap has key{
id: UID,
role_address:address,
}
由于没有store能力,不能通过dao module外的方式转移
核心成员权限凭证
struct CoreCap has key{
id: UID,
role_address:address,
}
由于没有store能力,不能通过dao module外的方式转移
成员权限凭证
struct MemberCap has key{
id: UID,
role_address:address,
}
社区任务
struct CommunityTask has key{
id:UID,
describe: String,
reward_amount: u64,
distribute_ended: bool,
}
包括任务描述,奖励金额,是否停止奖励等字段
任务奖励凭证
struct TaskRewardCap has key{
id:UID,
reward_amount: u64,
owner: address,
}
确认完成某社区任务下发的奖励凭证,以便任务完成申请奖励
提案
struct Proposal has key,store{
id: UID,
title: String, //The title of the proposal
describe: String, //Content of the Proposal
level: u64,
proposer: address, //Initiator of the Proposal
lock_balance: u64, //DAO Tokens Locked by the Proposal
support: u64, //Number of votes in favor of the proposal
against: u64, //Number of votes against the proposal
is_closed: bool,
is_passed: bool,
is_claimed_reward: bool,
}
提案obj,包括提案标题,描述,等级,提案者,投票总额,支持票,反对票,是否关闭,是否通过,是否被领取奖励字段
选票凭证
struct VoteCap has key{
id: UID,
proposal_id: ID,
voter: address,
is_support: bool,
votes: u64,
}
由于投票后会先收取选票,所以下发投票凭证,以便在提案结束后赎回选票
结语
我们初步构想了一个去中心化的dao组织,对其中重要的结构体进行设计实现。接下来,我们将会用代码一步步实现先前的设计,通过动手实践学习sui编程。
标签:社区,dao,struct,代币,move,sui,提案,id From: https://blog.csdn.net/2301_79429515/article/details/136784101