Remix에 작성한 간단한 Solidity 코드와 Aragon 플랫폼으로 DAO의 기본 기능을 구현할 수 있다.
<MyToken.sol>
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol";
contract MyToken is ERC20, Ownable, ERC20Permit, ERC20Votes {
constructor() ERC20("MyToken", "MTK") ERC20Permit("MyToken") {
_mint(msg.sender, 100 * 10 ** decimals());
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
// The following functions are overrides required by Solidity.
function _afterTokenTransfer(address from, address to, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._afterTokenTransfer(from, to, amount);
}
function _mint(address to, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._mint(to, amount);
}
function _burn(address account, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._burn(account, amount);
}
}
<MyGovernor.sol>
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/governance/Governor.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorCountingSimple.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotes.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotesQuorumFraction.sol";
contract MyGovernor is Governor, GovernorCountingSimple, GovernorVotes, GovernorVotesQuorumFraction {
constructor (IVotes _token)
Governor("MyGovernor")
GovernorVotes(_token)
GovernorVotesQuorumFraction(1)
{}
function votingDelay() public pure override returns (uint256) {
return 0; // 0 block
}
function votingPeriod() public pure override returns (uint256) {
return 50400; // 1 week
}
// The following functions are overrides required by Solidity.
function quorum(uint256 blockNumber)
public
view
override(IGovernor, GovernorVotesQuorumFraction)
returns (uint256)
{
return super.quorum(blockNumber);
}
}
Call
MyToken.delegate(0xMY_ADDRESS)
Verify delegate by callingMyToken.delgates(0xMY_ADDRESS)
Under
MyToken.transferOwnership(newOwner)
paste in0xMyGovernor
VerifyMyToken.owner()
matches0xMyGovernor
Call
MyGovernor.propose(targets, values, calldata, description)
targets
=0xMyToken
. This proposal will interact withMyToken
contract
values
=[0]
is the amount of native tokens (ETH) to send.
calldata
=0x40c1...
is what to call onMyToken
contract.
CallMyGovernance.hashProposal(targets, values, calldata, descriptionHash)
Call
MyGovernor.proposalVotes(proposalId)
Next, callMyGovernor.castVote(proposalId, support)
CallMyGovernor.proposalVotes(proposalId)
MyGovernor.proposalDeadline(proposalId)
Call
MyToken.balanceOf(0xAlice)
CallMyGovernor.execute(targets, values, calldata, descriptionHash)
Call
MyToken.balanceOf(0xAlice)
Sources : Medium
Metamask 지갑을 연동해 DAO 플랫폼인 Aragon으로 DAO를 만들고 체험할 수 있다.
Company,Membership, Reputation 중 원하는 템플릿을 선택해 DAO를 생성할 수 있다. Company 템플릿을 이용하면 소유권을 이전할 수 있는 토큰으로 의결권을 분배할 수 있다.
참여자에게 Token을 발행하고 보유량에 따라 의결권을 얻는다.
토큰 발행, 자금 지출 등에 대한 의사결정을 투표로 진행할 수 있다. 최소 찬성 비율과 최소 투표율이 충족되면 투표 내용이 받아들여져 실행된다.