Verified contractPartial
Association
Address0x25f226f9eb8990f8a4cd1c94ca0cdeffe0223c69
- Balance
0 ETH
- Transactions
4
- Compiler
solc 0.2.0
- Same code
Only this contract
Details
- Compiler
- solc 0.2.0+commit.4dc2445e
- Language
- solidity
- Optimization
- No
- License
- Not stated
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 730,505
- Creation transaction
- 0x2973548646…8f65ac7028
Association.sol
// Recovered by EthereumHistory (ethereumhistory.com) -sw
/* The token is used as a voting shares */
contract token { mapping (address => uint256) public balanceOf; }
/* The democracy contract itself */
contract Association {
/* Contract Variables and events */
uint public minimumQuorum;
uint public debatingPeriodInMinutes;
Proposal[] public proposals;
uint public numProposals;
token public sharesTokenAddress;
event ProposalAdded(uint proposalID, address recipient, uint amount, string description);
event Voted(uint proposalID, bool position, address voter);
event ProposalTallied(uint proposalID, int result, uint quorum, bool active);
struct Proposal {
address recipient;
uint amount;
string description;
uint creationDate;
bool active;
bool proposalPassed;
uint numberOfVotes;
bytes32 data;
Vote[] votes;
mapping (address => bool) voted;
}
struct Vote {
bool inSupport;
address voter;
}
/* modifier that allows only shareholders to vote and create new proposals */
modifier onlyShareholders {
if (sharesTokenAddress.balanceOf(msg.sender) == 0) throw;
_
}
/* First time setup */
function Association(token sharesAddress, uint minimumSharesForVoting, uint minutesForDebate) {
sharesTokenAddress = token(sharesAddress);
if (minimumSharesForVoting == 0 ) minimumSharesForVoting = 1;
minimumQuorum = minimumSharesForVoting;
debatingPeriodInMinutes = minutesForDebate;
}
/* Function to create a new proposal */
function newProposal(address beneficiary, uint etherAmount, string JobDescription, bytes32 transactionBytecode) onlyShareholders returns (uint proposalID) {
proposalID = proposals.length++;
Proposal p = proposals[proposalID];
p.recipient = beneficiary;
p.amount = etherAmount;
p.description = JobDescription;
p.data = transactionBytecode;
p.creationDate = now;
p.active = true;
p.proposalPassed = false;
p.numberOfVotes = 0;
ProposalAdded(proposalID, beneficiary, etherAmount, JobDescription);
numProposals = proposalID+1;
}
/* */
function vote(uint proposalNumber, bool supportsProposal) onlyShareholders returns (uint voteID){
Proposal p = proposals[proposalNumber];
if (p.voted[msg.sender] == true) throw;
voteID = p.votes.length++;
p.votes[voteID] = Vote({inSupport: supportsProposal, voter: msg.sender});
p.voted[msg.sender] = true;
p.numberOfVotes = voteID +1;
Voted(proposalNumber, supportsProposal, msg.sender);
}
function executeProposal(uint proposalNumber) returns (int result) {
Proposal p = proposals[proposalNumber];
if (now < p.creationDate + debatingPeriodInMinutes * 1 minutes || !p.active) throw;
/* tally the votes */
uint quorum = 0;
uint yea = 0;
uint nay = 0;
for (uint i = 0; i < p.votes.length; ++i) {
Vote v = p.votes[i];
uint voteWeight = sharesTokenAddress.balanceOf(v.voter);
quorum += voteWeight;
if (v.inSupport) {
yea += voteWeight;
} else {
nay += voteWeight;
}
}
/* execute result */
if (quorum > minimumQuorum && yea > nay) {
p.recipient.call.value(p.amount * 1 ether)(p.data);
p.active = false;
p.proposalPassed = true;
} else if (quorum > minimumQuorum && nay > yea) {
p.active = false;
p.proposalPassed = false;
}
// Fire Events
ProposalTallied(proposalNumber, result, quorum, p.active);
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.