首页 > 其他分享 >sui move开发实战-dao(1)

sui move开发实战-dao(1)

时间:2024-03-18 11:30:15浏览次数:17  
标签:社区 dao struct 代币 move sui 提案 id

引言

经过之前的学习,我准备进行实战开发一个简单的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.
权利:

  1. 发布社区任务
  2. 分发任务奖励
  3. 授权普通社区成员
  4. 关闭提案
  5. 修改提案等级
3.Member

dao组织的普通成员
权利:

  1. 发布提案
  2. 收获提案奖励
  3. 参与投票

如何运行

  1. DAO组织的初始成员发布社区任务
  2. 通过参与社区任务,持有dao代币,可以申请加入DAO组织
  3. 加入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

相关文章

  • python接口自动化测试 —— unittest框架suite、runner详细使用
    testsuite测试套件,理解成测试用例集一系列的测试用例,或测试套件,理解成测试用例的集合和测试套件的集合当运行测试套件时,则运行里面添加的所有测试用例testrunner测试运行器用于执行和输出结果的组件testsuite、testrunner基础使用单元测试类1#创建单元测试类......
  • 猫头虎分享已解决Bug | org.springframework.dao.DuplicateKeyException异常的正确解
    博主猫头虎的技术世界......
  • openGauss 由于RemoveIPC未关闭导致数据库crash
    openGauss由于RemoveIPC未关闭导致数据库crashsemop引发的数据库crash--主库FATAL:semop(id=xxxxx)failed:IdentifierremovedFATAL:semctl(xxxxxx,11,SETVAL,0)failed:Invalidargument--备库FATAL:semctl(xxxxxx,11,SETVAL,0)failed:InvalidargumentLOG......
  • 使用IDEA+groovy快速生成entity、dto、dao、service、serviceImpl
    groovy代码importcom.intellij.database.model.DasTableimportcom.intellij.database.util.Caseimportcom.intellij.database.util.DasUtilimportjava.text.SimpleDateFormat/**Availablecontextbindings:*SELECTIONIterable<DasObject>*PROJ......
  • [Rust] Thread 3: move keyword to resolve borrowing problem for closure
    Weofteruse movewithclosurespassedto thread::spawnbecasetheclosurewillthentakeownershipofthevaluesitusesfromtheenvironment,thustransferringowershopofthosevaluesfromonethreadtoanother. Thefollowingcodewon'twork:use......
  • The 2023 CCPC (Qinhuangdao) Onsite (The 2nd Universal Cup. Stage 9: Qinhuangdao)
    Preface完全披萨,最害怕的一集,2h过了5题后开始大坐牢环节徐神开D感觉是个巨复杂的字符串讨论题,一不注意就码了200+行然后我和祁神在下面讨论得出了I的做法,虽然是个DS题但上去写的时候一点自信没有最后摸了半天到比赛结束后1min才调出样例,赛后又调了半小时左右才过了这题唉这就......
  • burpsuit app 抓包 安卓7.0以上证书制作
    burpsuitapp抓包以及安卓7.0以上证书制作前言:今天在使用某校园跑脚本时需要上传token,只能抓包获取,但发现安卓7.0以上的证书不能直接导入,故记录一下制作以及导入方式。首先我们要从burpsuite的客户端或者官方网页获得证书,将证书放在kali中或其他带有openssl的linux系统中,对其......
  • BurpSuite使用教程
    BurpSuite使用教程BurpSuite是基于java环境运行,所以要安装java环境启动BurpSuite方式第一种:双击BurpSuite.jar,点击run进行进入第二种:命令启动或者创建一个.bat文件(批处理文件),写入命令,双击启动(该命令与第一种run旁边的命令一致)java-noverify-javaagent:burploader.jar-jar......
  • WeifenLuo.WinFormsUI.Docking学习
    转载:https://blog.csdn.net/gaoyunpeng/article/details/3873217?spm=1001.2101.3001.6650.4&utm_medium=distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-4.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-bl......
  • remote: Support for password authentication was removed on August 13, 2021.
    今天在pushcode的时候发现报了如下的错误remote:SupportforpasswordauthenticationwasremovedonAugust13,2021. 根据提示发现需要updategithub的token, https://github.com/settings/tokens  改好生成对应的token,记得保存好 gitpushhttps://<your_tok......