关于DAO社区治理dapp系统开发部署教程

简介: 关于DAO社区治理dapp系统开发部署教程,代币投票,管理

编写提议删除条目的函数:
投票删除和黑名单
三个条目删除功能:
1.删除条目:通过投票确认后,目标条目将被删除。投票时间:48小时。
2.紧急删除条目[仅限所有者]:只能由所有者触发。通过投票确认后,目标条目将被删除。投票时间:24小时。
3.紧急删除图像[仅限所有者]:仅适用于图像条目。开发对接唯hkkf5566只能由所有者触发。通过投票确认后,目标条目将被删除。投票时间:4小时。
单个地址条目的五个删除导致黑名单。
首先,删除功能:
modifier memberOnly() {

require(whitelist[msg.sender]);
require(!blacklist[msg.sender]);
_;

}

function proposeDeletion(bytes32 _hash, string _description) memberOnly public {

require(submissionExists(_hash), "Submission must exist to be deletable");

uint256 proposalId = proposals.length++;
Proposal storage p = proposals[proposalId];
p.description = _description;
p.executed = false;
p.creationDate = now;
p.submitter = msg.sender;
p.typeFlag = 1;
p.target = _hash;

p.deadline = now + 2 days;

emit ProposalAdded(proposalId, 1, _hash, _description, msg.sender);
proposalCount = proposalId + 1;

}

function proposeDeletionUrgent(bytes32 _hash, string _description) onlyOwner public {

require(submissionExists(_hash), "Submission must exist to be deletable");

uint256 proposalId = proposals.length++;
Proposal storage p = proposals[proposalId];
p.description = _description;
p.executed = false;
p.creationDate = now;
p.submitter = msg.sender;
p.typeFlag = 1;
p.target = _hash;

p.deadline = now + 12 hours;

emit ProposalAdded(proposalId, 1, _hash, _description, msg.sender);
proposalCount = proposalId + 1;

}

function proposeDeletionUrgentImage(bytes32 _hash, string _description) onlyOwner public {

require(submissions[_hash].image == true, "Submission must be existing image");

uint256 proposalId = proposals.length++;
Proposal storage p = proposals[proposalId];
p.description = _description;
p.executed = false;
p.creationDate = now;
p.submitter = msg.sender;
p.typeFlag = 1;
p.target = _hash;

p.deadline = now + 4 hours;

emit ProposalAdded(proposalId, 1, _hash, _description, msg.sender);
proposalCount = proposalId + 1;

}
一旦提出,建议书就会被添加到提案列表中,并记录条目哈希所针对的条目。保存说明并添加一些默认值,并根据提案类型计算截止日期。该提案添加了事件,并且提案总数增加了。
接下来看看如何执行提案。为了可执行,提案必须有足够的票数,并且必须超过其截止日期。执行功能将接受要执行的提议的ID。没有简单的方法可以让EVM立即执行所有待处理的提案。可能有太多人要等待执行,并且他们会对DAO中的数据进行大的更改,这可能会超过以太坊块的气体限制,从而导致交易失败。构建一个可以由具有明确规则的任何人调用的手动执行功能要容易得多,因此社区可以关注需要执行的提议。
function executeProposal(uint256 _id) public {

Proposal storage p = proposals[_id];
require(now >= p.deadline && !p.executed);

if (p.typeFlag == 1 && p.currentResult > 0) {
    assert(deleteSubmission(p.target));
}

uint256 len = p.votes.length;
for (uint i = 0; i 

通过其ID获取提案,检查它是否符合未执行的要求和截止日期过期,然后如果提案的类型是删除提案且投票结果是肯定的,我们使用已经写入的删除功能,最后发出了我们添加的新事件(将其添加到合约的顶部)。assert调用与require语句具有相同的用途:断言通常在“断言”结果为真时使用。要求用于先决条件。在功能上它们是相同的,assert语句的差异在它们失败时无法接受消息参数。该功能通过为该一个提案中的所有投票解锁代币而结束。
使用相同的方法添加其他类型的提案,但首先,更新deleteSubmission函数以禁止在其帐户上有五个或更多删除的用户:这意味着他们一直在提交社区投票反对的内容。更新deleteSubmission函数:
function deleteSubmission(bytes32 hash) internal returns (bool) {

require(submissionExists(hash), "Submission must exist to be deletable.");
Submission storage sub = submissions[hash];

sub.exists = false;
deletions[submissions[hash].submitter] += 1;
if (deletions[submissions[hash].submitter] >= 5) {
    blacklistAddress(submissions[hash].submitter);
}

emit SubmissionDeleted(
    sub.index,
    sub.content,
    sub.image,
    sub.submitter
);

nonDeletedSubmissions -= 1;
return true;

}
自动将五个删除列入黑名单。但是,如果不给黑名单地址提供赎回的机会,那是不公平的。需要定义黑名单功能本身。做这两件事并将不合理的费用设置为例如0.05以太。
function blacklistAddress(address _offender) internal {

require(blacklist[_offender] == false, "Can't blacklist a blacklisted user :/");
blacklist[_offender] == true;
token.increaseLockedAmount(_offender, token.getUnlockedAmount(_offender));
emit Blacklisted(_offender, true);

}

function unblacklistMe() payable public {

unblacklistAddress(msg.sender);

}

function unblacklistAddress(address _offender) payable public {

require(msg.value >= 0.05 ether, "Unblacklisting fee");
require(blacklist[_offender] == true, "Can't unblacklist a non-blacklisted user :/");
require(notVoting(_offender), "Offender must not be involved in a vote.");
withdrawableByOwner = withdrawableByOwner.add(msg.value);
blacklist[_offender] = false;
token.decreaseLockedAmount(_offender, token.balanceOf(_offender));
emit Blacklisted(_offender, false);

}

function notVoting(address _voter) internal view returns (bool) {

for (uint256 i = 0; i 

请注意,列入黑名单的帐户的令牌会被锁定,直到他们发送不合格的费用为止。

相关文章
|
存储 区块链 数据安全/隐私保护
DAO社区治理代币挖矿系统开发丨DAPP技术分析
DAO的生态系统是智能合约【180-系统3831-开发9724薇】和功能完善的社区的独特组合。与传统组织不同,DAO不受董事会或经理管理,而是由其成员管理,这些成员通过基于代币的投票机制集体管理DAO内的决策,这些投票机制根据智能合约中的预定义规则执行。
|
11月前
|
测试技术 数据安全/隐私保护 索引
DAO社区治理系统模式开发规则详情 | DAO社区治理系统开发源码示例(Python语言版)
DAO(Data Access Object)社区治理模式是一种去中心化的社区治理模式,它将权力下放到社区中,让社区成员自主决策、自我管理,从而实现社区的自主治理。在DAO社区治理模式中,权力下放到社区中,社区成员可以自由地发表自己的意见和建议,并且能够直接参与到社区的决策过程中。
|
区块链
去中心化社区治理代币模式DAO系统开发部署详细教程
去中心化社区治理代币模式DAO系统开发部署详细教程
|
2月前
|
新零售 供应链 数据挖掘
推三返一系统开发|成熟案例|源码部署
“新零售”的商业生态构建将涵盖网上页面
|
9月前
|
存储 前端开发 安全
DAPP区块链商城系统开发(方案逻辑)丨区块链DAPP商城系统开发(案例设计)/开发项目/源码部署
 区块链(Blockchain)是一种由多方共同维护,使用密码学保证传输和访问安全,能够实现数据一致存储、难以篡改、防止抵赖的记账技术,也称为分布式账本技术(Distributed Ledger Technology)。从本质上看,区块链是通过去中心化和去信任化,集体维护、分布式存储的可靠数据库。
|
9月前
|
存储 安全 区块链
IPPswap+NFTswap+OMNIswap智能合约项目系统开发方案项目及源码案例
  DApp是指基于区块练技术的去中心化应用程序,它的特点是去中心化、透明、安全、不可篡改等,DApp is an inevitable trend because it can solve problems such as centralization,data privacy,and security in traditional applications,while also achieving more fair,transparent,an
|
10月前
摩顿Mortonn(DAPP)项目系统开发技术方案
摩顿Mortonn(DAPP)项目系统开发技术方案
|
10月前
|
存储 人工智能 安全
Opsea NFT智能合约平台系统开发方案介绍/功能详解/源码说明/项目案例
  DAPP是去中心化应用程序(Decentralized Application),它是建立在区块练技术之上的应用程序,具有去中心化、开放性、透明性、安全性等特点,DAPP可以实现各种功能,例如数字货币钱包、去中心化交易所、去中心化社交网络等。O
|
10月前
|
存储 区块链
DAPP/DEFI节点算力平台系统开发案例设计/方案项目/源码平台
 区块链的核心技术之一就是公开且透明的交易信息。一般情况下,在区块链内产生、流转和存储的信息是对所有节点用户开放的,其高度的透明化也使得区块内的所有人都能够查看数据的所有相关信息同时使用其应用。Therefore,blockchain technology has certain advantages in the fields of information sharing and data exchange.
|
11月前
|
存储 区块链 数据安全/隐私保护
区块链会员系统开发功能搭建源码demo
以下是一个简单的区块链会员系统开发源码demo,包括区块链钱包、区块链溯源系统和智能合约:

热门文章

最新文章