Contract Overview
My Name Tag:
Not Available, login to update
[ Download CSV Export ]
Contract Name:
MuDAO
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
No with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract MuDAO{ enum VotingOptions { Yes, No } enum Status { Accepted, Rejected, Pending } struct Proposal { uint256 id; address author; string name; string description; uint256 createdAt; uint256 votesForYes; uint256 votesForNo; Status status; } // store all proposals mapping(uint => Proposal) public proposals; // who already votes for who and to avoid vote twice mapping(address => mapping(uint => bool)) public votes; // one share for governance tokens mapping(address => uint256) public shares; uint public totalShares; // the IERC20 allow us to use MUO like our governance token. IERC20 public token; // the user need minimum 25 MUO to create a proposal. uint constant CREATE_PROPOSAL_MIN_SHARE = 25 * 10 ** 18; uint constant VOTING_PERIOD = 14 days; uint public nextProposalId; constructor() { token = IERC20(0x561f2209eA45023d796bF42F0402B33bc26610ce); // MUO address } function deposit(uint _amount) external { shares[msg.sender] += _amount; totalShares += _amount; token.transferFrom(msg.sender, address(this), _amount); } function withdraw(uint _amount) external { require(shares[msg.sender] >= _amount, 'Not enough shares'); shares[msg.sender] -= _amount; totalShares -= _amount; token.transfer(msg.sender, _amount); } function createProposal(string memory name, string memory description) external { // validate the user has enough shares to create a proposal require(shares[msg.sender] >= CREATE_PROPOSAL_MIN_SHARE, 'Not enough shares to create a proposal'); proposals[nextProposalId] = Proposal( nextProposalId, msg.sender, name, description, block.timestamp, 0, 0, Status.Pending ); nextProposalId++; } function vote(uint _proposalId, VotingOptions _vote) external { Proposal storage proposal = proposals[_proposalId]; require(votes[msg.sender][_proposalId] == false, 'already voted'); require(block.timestamp <= proposal.createdAt + VOTING_PERIOD, 'Voting period is over'); votes[msg.sender][_proposalId] = true; if(_vote == VotingOptions.Yes) { proposal.votesForYes += shares[msg.sender]; if(proposal.votesForYes * 100 / totalShares > 50) { proposal.status = Status.Accepted; } } else { proposal.votesForNo += shares[msg.sender]; if(proposal.votesForNo * 100 / totalShares > 50) { proposal.status = Status.Rejected; } } } }
{ "optimizer": { "enabled": false, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"description","type":"string"}],"name":"createProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nextProposalId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"proposals","outputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"author","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"uint256","name":"createdAt","type":"uint256"},{"internalType":"uint256","name":"votesForYes","type":"uint256"},{"internalType":"uint256","name":"votesForNo","type":"uint256"},{"internalType":"enum MuDAO.Status","name":"status","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"shares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_proposalId","type":"uint256"},{"internalType":"enum MuDAO.VotingOptions","name":"_vote","type":"uint8"}],"name":"vote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"votes","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b5073561f2209ea45023d796bf42f0402b33bc26610ce600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611730806100756000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c8063943e821611610066578063943e82161461014e5780639f2524ee1461016a578063b6b55f251461019a578063ce7c2ac2146101b6578063fc0c546a146101e65761009e565b8063013cf08b146100a35780632ab09d14146100da5780632e1a7d4d146100f85780633a98ef391461011457806365e481e214610132575b600080fd5b6100bd60048036038101906100b89190610cbf565b610204565b6040516100d1989796959493929190610e4c565b60405180910390f35b6100e2610389565b6040516100ef9190610ed8565b60405180910390f35b610112600480360381019061010d9190610cbf565b61038f565b005b61011c610533565b6040516101299190610ed8565b60405180910390f35b61014c60048036038101906101479190611028565b610539565b005b610168600480360381019061016391906110c5565b610736565b005b610184600480360381019061017f9190611131565b610a41565b604051610191919061118c565b60405180910390f35b6101b460048036038101906101af9190610cbf565b610a70565b005b6101d060048036038101906101cb91906111a7565b610b94565b6040516101dd9190610ed8565b60405180910390f35b6101ee610bac565b6040516101fb9190611233565b60405180910390f35b60006020528060005260406000206000915090508060000154908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060020180546102539061127d565b80601f016020809104026020016040519081016040528092919081815260200182805461027f9061127d565b80156102cc5780601f106102a1576101008083540402835291602001916102cc565b820191906000526020600020905b8154815290600101906020018083116102af57829003601f168201915b5050505050908060030180546102e19061127d565b80601f016020809104026020016040519081016040528092919081815260200182805461030d9061127d565b801561035a5780601f1061032f5761010080835404028352916020019161035a565b820191906000526020600020905b81548152906001019060200180831161033d57829003601f168201915b5050505050908060040154908060050154908060060154908060070160009054906101000a900460ff16905088565b60055481565b80600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610411576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610408906112fb565b60405180910390fd5b80600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610460919061134a565b925050819055508060036000828254610479919061134a565b92505081905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b81526004016104dd92919061137e565b602060405180830381600087803b1580156104f757600080fd5b505af115801561050b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052f91906113d3565b5050565b60035481565b68015af1d78b58c40000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156105c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105bb90611472565b60405180910390fd5b60405180610100016040528060055481526020013373ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001428152602001600081526020016000815260200160028081111561062757610626610dd5565b5b81525060008060055481526020019081526020016000206000820151816000015560208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020190805190602001906106ab929190610bd2565b5060608201518160030190805190602001906106c8929190610bd2565b506080820151816004015560a0820151816005015560c0820151816006015560e08201518160070160006101000a81548160ff0219169083600281111561071257610711610dd5565b5b02179055509050506005600081548092919061072d90611492565b91905055505050565b6000806000848152602001908152602001600020905060001515600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085815260200190815260200160002060009054906101000a900460ff161515146107f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107e790611527565b60405180910390fd5b6212750081600401546108039190611547565b421115610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161083c906115e9565b60405180910390fd5b60018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085815260200190815260200160002060006101000a81548160ff021916908315150217905550600060018111156108c1576108c0610dd5565b5b8260018111156108d4576108d3610dd5565b5b141561098d57600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481600501600082825461092d9190611547565b9250508190555060326003546064836005015461094a9190611609565b6109549190611692565b11156109885760008160070160006101000a81548160ff0219169083600281111561098257610981610dd5565b5b02179055505b610a3c565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548160060160008282546109e09190611547565b925050819055506032600354606483600601546109fd9190611609565b610a079190611692565b1115610a3b5760018160070160006101000a81548160ff02191690836002811115610a3557610a34610dd5565b5b02179055505b5b505050565b60016020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b80600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610abf9190611547565b925050819055508060036000828254610ad89190611547565b92505081905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330846040518463ffffffff1660e01b8152600401610b3e939291906116c3565b602060405180830381600087803b158015610b5857600080fd5b505af1158015610b6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9091906113d3565b5050565b60026020528060005260406000206000915090505481565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b828054610bde9061127d565b90600052602060002090601f016020900481019282610c005760008555610c47565b82601f10610c1957805160ff1916838001178555610c47565b82800160010185558215610c47579182015b82811115610c46578251825591602001919060010190610c2b565b5b509050610c549190610c58565b5090565b5b80821115610c71576000816000905550600101610c59565b5090565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b610c9c81610c89565b8114610ca757600080fd5b50565b600081359050610cb981610c93565b92915050565b600060208284031215610cd557610cd4610c7f565b5b6000610ce384828501610caa565b91505092915050565b610cf581610c89565b82525050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610d2682610cfb565b9050919050565b610d3681610d1b565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d76578082015181840152602081019050610d5b565b83811115610d85576000848401525b50505050565b6000601f19601f8301169050919050565b6000610da782610d3c565b610db18185610d47565b9350610dc1818560208601610d58565b610dca81610d8b565b840191505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60038110610e1557610e14610dd5565b5b50565b6000819050610e2682610e04565b919050565b6000610e3682610e18565b9050919050565b610e4681610e2b565b82525050565b600061010082019050610e62600083018b610cec565b610e6f602083018a610d2d565b8181036040830152610e818189610d9c565b90508181036060830152610e958188610d9c565b9050610ea46080830187610cec565b610eb160a0830186610cec565b610ebe60c0830185610cec565b610ecb60e0830184610e3d565b9998505050505050505050565b6000602082019050610eed6000830184610cec565b92915050565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610f3582610d8b565b810181811067ffffffffffffffff82111715610f5457610f53610efd565b5b80604052505050565b6000610f67610c75565b9050610f738282610f2c565b919050565b600067ffffffffffffffff821115610f9357610f92610efd565b5b610f9c82610d8b565b9050602081019050919050565b82818337600083830152505050565b6000610fcb610fc684610f78565b610f5d565b905082815260208101848484011115610fe757610fe6610ef8565b5b610ff2848285610fa9565b509392505050565b600082601f83011261100f5761100e610ef3565b5b813561101f848260208601610fb8565b91505092915050565b6000806040838503121561103f5761103e610c7f565b5b600083013567ffffffffffffffff81111561105d5761105c610c84565b5b61106985828601610ffa565b925050602083013567ffffffffffffffff81111561108a57611089610c84565b5b61109685828601610ffa565b9150509250929050565b600281106110ad57600080fd5b50565b6000813590506110bf816110a0565b92915050565b600080604083850312156110dc576110db610c7f565b5b60006110ea85828601610caa565b92505060206110fb858286016110b0565b9150509250929050565b61110e81610d1b565b811461111957600080fd5b50565b60008135905061112b81611105565b92915050565b6000806040838503121561114857611147610c7f565b5b60006111568582860161111c565b925050602061116785828601610caa565b9150509250929050565b60008115159050919050565b61118681611171565b82525050565b60006020820190506111a1600083018461117d565b92915050565b6000602082840312156111bd576111bc610c7f565b5b60006111cb8482850161111c565b91505092915050565b6000819050919050565b60006111f96111f46111ef84610cfb565b6111d4565b610cfb565b9050919050565b600061120b826111de565b9050919050565b600061121d82611200565b9050919050565b61122d81611212565b82525050565b60006020820190506112486000830184611224565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061129557607f821691505b602082108114156112a9576112a861124e565b5b50919050565b7f4e6f7420656e6f75676820736861726573000000000000000000000000000000600082015250565b60006112e5601183610d47565b91506112f0826112af565b602082019050919050565b60006020820190508181036000830152611314816112d8565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061135582610c89565b915061136083610c89565b9250828210156113735761137261131b565b5b828203905092915050565b60006040820190506113936000830185610d2d565b6113a06020830184610cec565b9392505050565b6113b081611171565b81146113bb57600080fd5b50565b6000815190506113cd816113a7565b92915050565b6000602082840312156113e9576113e8610c7f565b5b60006113f7848285016113be565b91505092915050565b7f4e6f7420656e6f7567682073686172657320746f20637265617465206120707260008201527f6f706f73616c0000000000000000000000000000000000000000000000000000602082015250565b600061145c602683610d47565b915061146782611400565b604082019050919050565b6000602082019050818103600083015261148b8161144f565b9050919050565b600061149d82610c89565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156114d0576114cf61131b565b5b600182019050919050565b7f616c726561647920766f74656400000000000000000000000000000000000000600082015250565b6000611511600d83610d47565b915061151c826114db565b602082019050919050565b6000602082019050818103600083015261154081611504565b9050919050565b600061155282610c89565b915061155d83610c89565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156115925761159161131b565b5b828201905092915050565b7f566f74696e6720706572696f64206973206f7665720000000000000000000000600082015250565b60006115d3601583610d47565b91506115de8261159d565b602082019050919050565b60006020820190508181036000830152611602816115c6565b9050919050565b600061161482610c89565b915061161f83610c89565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156116585761165761131b565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061169d82610c89565b91506116a883610c89565b9250826116b8576116b7611663565b5b828204905092915050565b60006060820190506116d86000830186610d2d565b6116e56020830185610d2d565b6116f26040830184610cec565b94935050505056fea264697066735822122028825cd3a5460036022caf75fe17cd365f712e7460dfa8adc7a6eb2e431766af64736f6c63430008090033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.